ホーム › Globalization › GetNLSVersionEx
GetNLSVersionEx
関数指定ロケールのNLS機能のバージョン情報を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL GetNLSVersionEx(
DWORD function,
LPCWSTR lpLocaleName, // optional
NLSVERSIONINFOEX* lpVersionInformation
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| function | DWORD | in |
| lpLocaleName | LPCWSTR | inoptional |
| lpVersionInformation | NLSVERSIONINFOEX* | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL GetNLSVersionEx(
DWORD function,
LPCWSTR lpLocaleName, // optional
NLSVERSIONINFOEX* lpVersionInformation
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetNLSVersionEx(
uint function, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpLocaleName, // LPCWSTR optional
IntPtr lpVersionInformation // NLSVERSIONINFOEX* in/out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetNLSVersionEx(
[function] As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpLocaleName As String, ' LPCWSTR optional
lpVersionInformation As IntPtr ' NLSVERSIONINFOEX* in/out
) As Boolean
End Function' function : DWORD
' lpLocaleName : LPCWSTR optional
' lpVersionInformation : NLSVERSIONINFOEX* in/out
Declare PtrSafe Function GetNLSVersionEx Lib "kernel32" ( _
ByVal function As Long, _
ByVal lpLocaleName As LongPtr, _
ByVal lpVersionInformation As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetNLSVersionEx = ctypes.windll.kernel32.GetNLSVersionEx
GetNLSVersionEx.restype = wintypes.BOOL
GetNLSVersionEx.argtypes = [
wintypes.DWORD, # function : DWORD
wintypes.LPCWSTR, # lpLocaleName : LPCWSTR optional
ctypes.c_void_p, # lpVersionInformation : NLSVERSIONINFOEX* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetNLSVersionEx = Fiddle::Function.new(
lib['GetNLSVersionEx'],
[
-Fiddle::TYPE_INT, # function : DWORD
Fiddle::TYPE_VOIDP, # lpLocaleName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # lpVersionInformation : NLSVERSIONINFOEX* in/out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetNLSVersionEx(
function: u32, // DWORD
lpLocaleName: *const u16, // LPCWSTR optional
lpVersionInformation: *mut NLSVERSIONINFOEX // NLSVERSIONINFOEX* in/out
) -> 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 GetNLSVersionEx(uint function, [MarshalAs(UnmanagedType.LPWStr)] string lpLocaleName, IntPtr lpVersionInformation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetNLSVersionEx' -Namespace Win32 -PassThru
# $api::GetNLSVersionEx(function, lpLocaleName, lpVersionInformation)#uselib "KERNEL32.dll"
#func global GetNLSVersionEx "GetNLSVersionEx" sptr, sptr, sptr
; GetNLSVersionEx function, lpLocaleName, varptr(lpVersionInformation) ; 戻り値は stat
; function : DWORD -> "sptr"
; lpLocaleName : LPCWSTR optional -> "sptr"
; lpVersionInformation : NLSVERSIONINFOEX* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetNLSVersionEx "GetNLSVersionEx" int, wstr, var ; res = GetNLSVersionEx(function, lpLocaleName, lpVersionInformation) ; function : DWORD -> "int" ; lpLocaleName : LPCWSTR optional -> "wstr" ; lpVersionInformation : NLSVERSIONINFOEX* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetNLSVersionEx "GetNLSVersionEx" int, wstr, sptr ; res = GetNLSVersionEx(function, lpLocaleName, varptr(lpVersionInformation)) ; function : DWORD -> "int" ; lpLocaleName : LPCWSTR optional -> "wstr" ; lpVersionInformation : NLSVERSIONINFOEX* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetNLSVersionEx(DWORD function, LPCWSTR lpLocaleName, NLSVERSIONINFOEX* lpVersionInformation) #uselib "KERNEL32.dll" #cfunc global GetNLSVersionEx "GetNLSVersionEx" int, wstr, var ; res = GetNLSVersionEx(function, lpLocaleName, lpVersionInformation) ; function : DWORD -> "int" ; lpLocaleName : LPCWSTR optional -> "wstr" ; lpVersionInformation : NLSVERSIONINFOEX* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetNLSVersionEx(DWORD function, LPCWSTR lpLocaleName, NLSVERSIONINFOEX* lpVersionInformation) #uselib "KERNEL32.dll" #cfunc global GetNLSVersionEx "GetNLSVersionEx" int, wstr, intptr ; res = GetNLSVersionEx(function, lpLocaleName, varptr(lpVersionInformation)) ; function : DWORD -> "int" ; lpLocaleName : LPCWSTR optional -> "wstr" ; lpVersionInformation : NLSVERSIONINFOEX* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetNLSVersionEx = kernel32.NewProc("GetNLSVersionEx")
)
// function (DWORD), lpLocaleName (LPCWSTR optional), lpVersionInformation (NLSVERSIONINFOEX* in/out)
r1, _, err := procGetNLSVersionEx.Call(
uintptr(function),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpLocaleName))),
uintptr(lpVersionInformation),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetNLSVersionEx(
function: DWORD; // DWORD
lpLocaleName: PWideChar; // LPCWSTR optional
lpVersionInformation: Pointer // NLSVERSIONINFOEX* in/out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'GetNLSVersionEx';result := DllCall("KERNEL32\GetNLSVersionEx"
, "UInt", function ; DWORD
, "WStr", lpLocaleName ; LPCWSTR optional
, "Ptr", lpVersionInformation ; NLSVERSIONINFOEX* in/out
, "Int") ; return: BOOL●GetNLSVersionEx(function, lpLocaleName, lpVersionInformation) = DLL("KERNEL32.dll", "bool GetNLSVersionEx(dword, char*, void*)")
# 呼び出し: GetNLSVersionEx(function, lpLocaleName, lpVersionInformation)
# function : DWORD -> "dword"
# lpLocaleName : LPCWSTR optional -> "char*"
# lpVersionInformation : NLSVERSIONINFOEX* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。