ホーム › Globalization › GetStringScripts
GetStringScripts
関数文字列に含まれるスクリプトの一覧を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
INT GetStringScripts(
DWORD dwFlags,
LPCWSTR lpString,
INT cchString,
LPWSTR lpScripts, // optional
INT cchScripts
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwFlags | DWORD | in |
| lpString | LPCWSTR | in |
| cchString | INT | in |
| lpScripts | LPWSTR | outoptional |
| cchScripts | INT | in |
戻り値の型: INT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
INT GetStringScripts(
DWORD dwFlags,
LPCWSTR lpString,
INT cchString,
LPWSTR lpScripts, // optional
INT cchScripts
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern int GetStringScripts(
uint dwFlags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpString, // LPCWSTR
int cchString, // INT
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpScripts, // LPWSTR optional, out
int cchScripts // INT
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetStringScripts(
dwFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpString As String, ' LPCWSTR
cchString As Integer, ' INT
<MarshalAs(UnmanagedType.LPWStr)> lpScripts As System.Text.StringBuilder, ' LPWSTR optional, out
cchScripts As Integer ' INT
) As Integer
End Function' dwFlags : DWORD
' lpString : LPCWSTR
' cchString : INT
' lpScripts : LPWSTR optional, out
' cchScripts : INT
Declare PtrSafe Function GetStringScripts Lib "kernel32" ( _
ByVal dwFlags As Long, _
ByVal lpString As LongPtr, _
ByVal cchString As Long, _
ByVal lpScripts As LongPtr, _
ByVal cchScripts As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetStringScripts = ctypes.windll.kernel32.GetStringScripts
GetStringScripts.restype = ctypes.c_int
GetStringScripts.argtypes = [
wintypes.DWORD, # dwFlags : DWORD
wintypes.LPCWSTR, # lpString : LPCWSTR
ctypes.c_int, # cchString : INT
wintypes.LPWSTR, # lpScripts : LPWSTR optional, out
ctypes.c_int, # cchScripts : INT
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetStringScripts = Fiddle::Function.new(
lib['GetStringScripts'],
[
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # lpString : LPCWSTR
Fiddle::TYPE_INT, # cchString : INT
Fiddle::TYPE_VOIDP, # lpScripts : LPWSTR optional, out
Fiddle::TYPE_INT, # cchScripts : INT
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetStringScripts(
dwFlags: u32, // DWORD
lpString: *const u16, // LPCWSTR
cchString: i32, // INT
lpScripts: *mut u16, // LPWSTR optional, out
cchScripts: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern int GetStringScripts(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string lpString, int cchString, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpScripts, int cchScripts);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetStringScripts' -Namespace Win32 -PassThru
# $api::GetStringScripts(dwFlags, lpString, cchString, lpScripts, cchScripts)#uselib "KERNEL32.dll"
#func global GetStringScripts "GetStringScripts" sptr, sptr, sptr, sptr, sptr
; GetStringScripts dwFlags, lpString, cchString, varptr(lpScripts), cchScripts ; 戻り値は stat
; dwFlags : DWORD -> "sptr"
; lpString : LPCWSTR -> "sptr"
; cchString : INT -> "sptr"
; lpScripts : LPWSTR optional, out -> "sptr"
; cchScripts : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetStringScripts "GetStringScripts" int, wstr, int, var, int ; res = GetStringScripts(dwFlags, lpString, cchString, lpScripts, cchScripts) ; dwFlags : DWORD -> "int" ; lpString : LPCWSTR -> "wstr" ; cchString : INT -> "int" ; lpScripts : LPWSTR optional, out -> "var" ; cchScripts : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetStringScripts "GetStringScripts" int, wstr, int, sptr, int ; res = GetStringScripts(dwFlags, lpString, cchString, varptr(lpScripts), cchScripts) ; dwFlags : DWORD -> "int" ; lpString : LPCWSTR -> "wstr" ; cchString : INT -> "int" ; lpScripts : LPWSTR optional, out -> "sptr" ; cchScripts : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT GetStringScripts(DWORD dwFlags, LPCWSTR lpString, INT cchString, LPWSTR lpScripts, INT cchScripts) #uselib "KERNEL32.dll" #cfunc global GetStringScripts "GetStringScripts" int, wstr, int, var, int ; res = GetStringScripts(dwFlags, lpString, cchString, lpScripts, cchScripts) ; dwFlags : DWORD -> "int" ; lpString : LPCWSTR -> "wstr" ; cchString : INT -> "int" ; lpScripts : LPWSTR optional, out -> "var" ; cchScripts : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT GetStringScripts(DWORD dwFlags, LPCWSTR lpString, INT cchString, LPWSTR lpScripts, INT cchScripts) #uselib "KERNEL32.dll" #cfunc global GetStringScripts "GetStringScripts" int, wstr, int, intptr, int ; res = GetStringScripts(dwFlags, lpString, cchString, varptr(lpScripts), cchScripts) ; dwFlags : DWORD -> "int" ; lpString : LPCWSTR -> "wstr" ; cchString : INT -> "int" ; lpScripts : LPWSTR optional, out -> "intptr" ; cchScripts : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetStringScripts = kernel32.NewProc("GetStringScripts")
)
// dwFlags (DWORD), lpString (LPCWSTR), cchString (INT), lpScripts (LPWSTR optional, out), cchScripts (INT)
r1, _, err := procGetStringScripts.Call(
uintptr(dwFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpString))),
uintptr(cchString),
uintptr(lpScripts),
uintptr(cchScripts),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction GetStringScripts(
dwFlags: DWORD; // DWORD
lpString: PWideChar; // LPCWSTR
cchString: Integer; // INT
lpScripts: PWideChar; // LPWSTR optional, out
cchScripts: Integer // INT
): Integer; stdcall;
external 'KERNEL32.dll' name 'GetStringScripts';result := DllCall("KERNEL32\GetStringScripts"
, "UInt", dwFlags ; DWORD
, "WStr", lpString ; LPCWSTR
, "Int", cchString ; INT
, "Ptr", lpScripts ; LPWSTR optional, out
, "Int", cchScripts ; INT
, "Int") ; return: INT●GetStringScripts(dwFlags, lpString, cchString, lpScripts, cchScripts) = DLL("KERNEL32.dll", "int GetStringScripts(dword, char*, int, char*, int)")
# 呼び出し: GetStringScripts(dwFlags, lpString, cchString, lpScripts, cchScripts)
# dwFlags : DWORD -> "dword"
# lpString : LPCWSTR -> "char*"
# cchString : INT -> "int"
# lpScripts : LPWSTR optional, out -> "char*"
# cchScripts : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。