Win32 API 日本語リファレンス
ホームGlobalization › GetNLSVersion

GetNLSVersion

関数
指定ロケールのNLS機能のバージョン情報を取得する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL GetNLSVersion(
    DWORD Function,
    DWORD Locale,
    NLSVERSIONINFO* lpVersionInformation
);

パラメーター

名前方向
FunctionDWORDin
LocaleDWORDin
lpVersionInformationNLSVERSIONINFO*inout

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL GetNLSVersion(
    DWORD Function,
    DWORD Locale,
    NLSVERSIONINFO* lpVersionInformation
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetNLSVersion(
    uint Function,   // DWORD
    uint Locale,   // DWORD
    IntPtr lpVersionInformation   // NLSVERSIONINFO* in/out
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetNLSVersion(
    [Function] As UInteger,   ' DWORD
    Locale As UInteger,   ' DWORD
    lpVersionInformation As IntPtr   ' NLSVERSIONINFO* in/out
) As Boolean
End Function
' Function : DWORD
' Locale : DWORD
' lpVersionInformation : NLSVERSIONINFO* in/out
Declare PtrSafe Function GetNLSVersion Lib "kernel32" ( _
    ByVal Function As Long, _
    ByVal Locale As Long, _
    ByVal lpVersionInformation As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetNLSVersion = ctypes.windll.kernel32.GetNLSVersion
GetNLSVersion.restype = wintypes.BOOL
GetNLSVersion.argtypes = [
    wintypes.DWORD,  # Function : DWORD
    wintypes.DWORD,  # Locale : DWORD
    ctypes.c_void_p,  # lpVersionInformation : NLSVERSIONINFO* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetNLSVersion = Fiddle::Function.new(
  lib['GetNLSVersion'],
  [
    -Fiddle::TYPE_INT,  # Function : DWORD
    -Fiddle::TYPE_INT,  # Locale : DWORD
    Fiddle::TYPE_VOIDP,  # lpVersionInformation : NLSVERSIONINFO* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn GetNLSVersion(
        Function: u32,  // DWORD
        Locale: u32,  // DWORD
        lpVersionInformation: *mut NLSVERSIONINFO  // NLSVERSIONINFO* 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 GetNLSVersion(uint Function, uint Locale, IntPtr lpVersionInformation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetNLSVersion' -Namespace Win32 -PassThru
# $api::GetNLSVersion(Function, Locale, lpVersionInformation)
#uselib "KERNEL32.dll"
#func global GetNLSVersion "GetNLSVersion" sptr, sptr, sptr
; GetNLSVersion Function, Locale, varptr(lpVersionInformation)   ; 戻り値は stat
; Function : DWORD -> "sptr"
; Locale : DWORD -> "sptr"
; lpVersionInformation : NLSVERSIONINFO* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global GetNLSVersion "GetNLSVersion" int, int, var
; res = GetNLSVersion(Function, Locale, lpVersionInformation)
; Function : DWORD -> "int"
; Locale : DWORD -> "int"
; lpVersionInformation : NLSVERSIONINFO* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetNLSVersion(DWORD Function, DWORD Locale, NLSVERSIONINFO* lpVersionInformation)
#uselib "KERNEL32.dll"
#cfunc global GetNLSVersion "GetNLSVersion" int, int, var
; res = GetNLSVersion(Function, Locale, lpVersionInformation)
; Function : DWORD -> "int"
; Locale : DWORD -> "int"
; lpVersionInformation : NLSVERSIONINFO* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetNLSVersion = kernel32.NewProc("GetNLSVersion")
)

// Function (DWORD), Locale (DWORD), lpVersionInformation (NLSVERSIONINFO* in/out)
r1, _, err := procGetNLSVersion.Call(
	uintptr(Function),
	uintptr(Locale),
	uintptr(lpVersionInformation),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetNLSVersion(
  Function: DWORD;   // DWORD
  Locale: DWORD;   // DWORD
  lpVersionInformation: Pointer   // NLSVERSIONINFO* in/out
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'GetNLSVersion';
result := DllCall("KERNEL32\GetNLSVersion"
    , "UInt", Function   ; DWORD
    , "UInt", Locale   ; DWORD
    , "Ptr", lpVersionInformation   ; NLSVERSIONINFO* in/out
    , "Int")   ; return: BOOL
●GetNLSVersion(Function, Locale, lpVersionInformation) = DLL("KERNEL32.dll", "bool GetNLSVersion(dword, dword, void*)")
# 呼び出し: GetNLSVersion(Function, Locale, lpVersionInformation)
# Function : DWORD -> "dword"
# Locale : DWORD -> "dword"
# lpVersionInformation : NLSVERSIONINFO* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。