ホーム › Globalization › VerifyScripts
VerifyScripts
関数テスト文字列がロケール許可スクリプトのみで構成されるか検証する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL VerifyScripts(
DWORD dwFlags,
LPCWSTR lpLocaleScripts,
INT cchLocaleScripts,
LPCWSTR lpTestScripts,
INT cchTestScripts
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwFlags | DWORD | in |
| lpLocaleScripts | LPCWSTR | in |
| cchLocaleScripts | INT | in |
| lpTestScripts | LPCWSTR | in |
| cchTestScripts | INT | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL VerifyScripts(
DWORD dwFlags,
LPCWSTR lpLocaleScripts,
INT cchLocaleScripts,
LPCWSTR lpTestScripts,
INT cchTestScripts
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool VerifyScripts(
uint dwFlags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpLocaleScripts, // LPCWSTR
int cchLocaleScripts, // INT
[MarshalAs(UnmanagedType.LPWStr)] string lpTestScripts, // LPCWSTR
int cchTestScripts // INT
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function VerifyScripts(
dwFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpLocaleScripts As String, ' LPCWSTR
cchLocaleScripts As Integer, ' INT
<MarshalAs(UnmanagedType.LPWStr)> lpTestScripts As String, ' LPCWSTR
cchTestScripts As Integer ' INT
) As Boolean
End Function' dwFlags : DWORD
' lpLocaleScripts : LPCWSTR
' cchLocaleScripts : INT
' lpTestScripts : LPCWSTR
' cchTestScripts : INT
Declare PtrSafe Function VerifyScripts Lib "kernel32" ( _
ByVal dwFlags As Long, _
ByVal lpLocaleScripts As LongPtr, _
ByVal cchLocaleScripts As Long, _
ByVal lpTestScripts As LongPtr, _
ByVal cchTestScripts As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
VerifyScripts = ctypes.windll.kernel32.VerifyScripts
VerifyScripts.restype = wintypes.BOOL
VerifyScripts.argtypes = [
wintypes.DWORD, # dwFlags : DWORD
wintypes.LPCWSTR, # lpLocaleScripts : LPCWSTR
ctypes.c_int, # cchLocaleScripts : INT
wintypes.LPCWSTR, # lpTestScripts : LPCWSTR
ctypes.c_int, # cchTestScripts : INT
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
VerifyScripts = Fiddle::Function.new(
lib['VerifyScripts'],
[
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # lpLocaleScripts : LPCWSTR
Fiddle::TYPE_INT, # cchLocaleScripts : INT
Fiddle::TYPE_VOIDP, # lpTestScripts : LPCWSTR
Fiddle::TYPE_INT, # cchTestScripts : INT
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn VerifyScripts(
dwFlags: u32, // DWORD
lpLocaleScripts: *const u16, // LPCWSTR
cchLocaleScripts: i32, // INT
lpTestScripts: *const u16, // LPCWSTR
cchTestScripts: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool VerifyScripts(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string lpLocaleScripts, int cchLocaleScripts, [MarshalAs(UnmanagedType.LPWStr)] string lpTestScripts, int cchTestScripts);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_VerifyScripts' -Namespace Win32 -PassThru
# $api::VerifyScripts(dwFlags, lpLocaleScripts, cchLocaleScripts, lpTestScripts, cchTestScripts)#uselib "KERNEL32.dll"
#func global VerifyScripts "VerifyScripts" sptr, sptr, sptr, sptr, sptr
; VerifyScripts dwFlags, lpLocaleScripts, cchLocaleScripts, lpTestScripts, cchTestScripts ; 戻り値は stat
; dwFlags : DWORD -> "sptr"
; lpLocaleScripts : LPCWSTR -> "sptr"
; cchLocaleScripts : INT -> "sptr"
; lpTestScripts : LPCWSTR -> "sptr"
; cchTestScripts : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global VerifyScripts "VerifyScripts" int, wstr, int, wstr, int
; res = VerifyScripts(dwFlags, lpLocaleScripts, cchLocaleScripts, lpTestScripts, cchTestScripts)
; dwFlags : DWORD -> "int"
; lpLocaleScripts : LPCWSTR -> "wstr"
; cchLocaleScripts : INT -> "int"
; lpTestScripts : LPCWSTR -> "wstr"
; cchTestScripts : INT -> "int"; BOOL VerifyScripts(DWORD dwFlags, LPCWSTR lpLocaleScripts, INT cchLocaleScripts, LPCWSTR lpTestScripts, INT cchTestScripts)
#uselib "KERNEL32.dll"
#cfunc global VerifyScripts "VerifyScripts" int, wstr, int, wstr, int
; res = VerifyScripts(dwFlags, lpLocaleScripts, cchLocaleScripts, lpTestScripts, cchTestScripts)
; dwFlags : DWORD -> "int"
; lpLocaleScripts : LPCWSTR -> "wstr"
; cchLocaleScripts : INT -> "int"
; lpTestScripts : LPCWSTR -> "wstr"
; cchTestScripts : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procVerifyScripts = kernel32.NewProc("VerifyScripts")
)
// dwFlags (DWORD), lpLocaleScripts (LPCWSTR), cchLocaleScripts (INT), lpTestScripts (LPCWSTR), cchTestScripts (INT)
r1, _, err := procVerifyScripts.Call(
uintptr(dwFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpLocaleScripts))),
uintptr(cchLocaleScripts),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpTestScripts))),
uintptr(cchTestScripts),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction VerifyScripts(
dwFlags: DWORD; // DWORD
lpLocaleScripts: PWideChar; // LPCWSTR
cchLocaleScripts: Integer; // INT
lpTestScripts: PWideChar; // LPCWSTR
cchTestScripts: Integer // INT
): BOOL; stdcall;
external 'KERNEL32.dll' name 'VerifyScripts';result := DllCall("KERNEL32\VerifyScripts"
, "UInt", dwFlags ; DWORD
, "WStr", lpLocaleScripts ; LPCWSTR
, "Int", cchLocaleScripts ; INT
, "WStr", lpTestScripts ; LPCWSTR
, "Int", cchTestScripts ; INT
, "Int") ; return: BOOL●VerifyScripts(dwFlags, lpLocaleScripts, cchLocaleScripts, lpTestScripts, cchTestScripts) = DLL("KERNEL32.dll", "bool VerifyScripts(dword, char*, int, char*, int)")
# 呼び出し: VerifyScripts(dwFlags, lpLocaleScripts, cchLocaleScripts, lpTestScripts, cchTestScripts)
# dwFlags : DWORD -> "dword"
# lpLocaleScripts : LPCWSTR -> "char*"
# cchLocaleScripts : INT -> "int"
# lpTestScripts : LPCWSTR -> "char*"
# cchTestScripts : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。