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