ホーム › System.SystemInformation › GetNativeSystemInfo
GetNativeSystemInfo
関数WOW64を考慮したネイティブのシステム情報を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
void GetNativeSystemInfo(
SYSTEM_INFO* lpSystemInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpSystemInfo | SYSTEM_INFO* | out |
戻り値の型: void
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
void GetNativeSystemInfo(
SYSTEM_INFO* lpSystemInfo
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern void GetNativeSystemInfo(
IntPtr lpSystemInfo // SYSTEM_INFO* out
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Sub GetNativeSystemInfo(
lpSystemInfo As IntPtr ' SYSTEM_INFO* out
)
End Sub' lpSystemInfo : SYSTEM_INFO* out
Declare PtrSafe Sub GetNativeSystemInfo Lib "kernel32" ( _
ByVal lpSystemInfo As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetNativeSystemInfo = ctypes.windll.kernel32.GetNativeSystemInfo
GetNativeSystemInfo.restype = None
GetNativeSystemInfo.argtypes = [
ctypes.c_void_p, # lpSystemInfo : SYSTEM_INFO* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetNativeSystemInfo = Fiddle::Function.new(
lib['GetNativeSystemInfo'],
[
Fiddle::TYPE_VOIDP, # lpSystemInfo : SYSTEM_INFO* out
],
Fiddle::TYPE_VOID)#[link(name = "kernel32")]
extern "system" {
fn GetNativeSystemInfo(
lpSystemInfo: *mut SYSTEM_INFO // SYSTEM_INFO* out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern void GetNativeSystemInfo(IntPtr lpSystemInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetNativeSystemInfo' -Namespace Win32 -PassThru
# $api::GetNativeSystemInfo(lpSystemInfo)#uselib "KERNEL32.dll"
#func global GetNativeSystemInfo "GetNativeSystemInfo" sptr
; GetNativeSystemInfo varptr(lpSystemInfo)
; lpSystemInfo : SYSTEM_INFO* out -> "sptr"出力引数:
#uselib "KERNEL32.dll" #func global GetNativeSystemInfo "GetNativeSystemInfo" var ; GetNativeSystemInfo lpSystemInfo ; lpSystemInfo : SYSTEM_INFO* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #func global GetNativeSystemInfo "GetNativeSystemInfo" sptr ; GetNativeSystemInfo varptr(lpSystemInfo) ; lpSystemInfo : SYSTEM_INFO* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void GetNativeSystemInfo(SYSTEM_INFO* lpSystemInfo) #uselib "KERNEL32.dll" #func global GetNativeSystemInfo "GetNativeSystemInfo" var ; GetNativeSystemInfo lpSystemInfo ; lpSystemInfo : SYSTEM_INFO* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void GetNativeSystemInfo(SYSTEM_INFO* lpSystemInfo) #uselib "KERNEL32.dll" #func global GetNativeSystemInfo "GetNativeSystemInfo" intptr ; GetNativeSystemInfo varptr(lpSystemInfo) ; lpSystemInfo : SYSTEM_INFO* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetNativeSystemInfo = kernel32.NewProc("GetNativeSystemInfo")
)
// lpSystemInfo (SYSTEM_INFO* out)
r1, _, err := procGetNativeSystemInfo.Call(
uintptr(lpSystemInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure GetNativeSystemInfo(
lpSystemInfo: Pointer // SYSTEM_INFO* out
); stdcall;
external 'KERNEL32.dll' name 'GetNativeSystemInfo';result := DllCall("KERNEL32\GetNativeSystemInfo"
, "Ptr", lpSystemInfo ; SYSTEM_INFO* out
, "Int") ; return: void●GetNativeSystemInfo(lpSystemInfo) = DLL("KERNEL32.dll", "int GetNativeSystemInfo(void*)")
# 呼び出し: GetNativeSystemInfo(lpSystemInfo)
# lpSystemInfo : SYSTEM_INFO* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。