Win32 API 日本語リファレンス
ホームSystem.SystemInformation › GetSystemInfo

GetSystemInfo

関数
プロセッサや構成など現在のシステム情報を取得する。
DLLKERNEL32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

void GetSystemInfo(
    SYSTEM_INFO* lpSystemInfo
);

パラメーター

名前方向
lpSystemInfoSYSTEM_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 方式にも切替可。
出力引数:
; void GetSystemInfo(SYSTEM_INFO* lpSystemInfo)
#uselib "KERNEL32.dll"
#func global GetSystemInfo "GetSystemInfo" var
; GetSystemInfo lpSystemInfo
; lpSystemInfo : SYSTEM_INFO* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。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   // void
procedure 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)。