ホーム › System.SystemInformation › GetSystemCpuSetInformation
GetSystemCpuSetInformation
関数システムのCPUセット情報を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL GetSystemCpuSetInformation(
SYSTEM_CPU_SET_INFORMATION* Information, // optional
DWORD BufferLength,
DWORD* ReturnedLength,
HANDLE Process, // optional
DWORD Flags // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Information | SYSTEM_CPU_SET_INFORMATION* | outoptional |
| BufferLength | DWORD | in |
| ReturnedLength | DWORD* | out |
| Process | HANDLE | inoptional |
| Flags | DWORD | optional |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL GetSystemCpuSetInformation(
SYSTEM_CPU_SET_INFORMATION* Information, // optional
DWORD BufferLength,
DWORD* ReturnedLength,
HANDLE Process, // optional
DWORD Flags // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool GetSystemCpuSetInformation(
IntPtr Information, // SYSTEM_CPU_SET_INFORMATION* optional, out
uint BufferLength, // DWORD
out uint ReturnedLength, // DWORD* out
IntPtr Process, // HANDLE optional
uint Flags // DWORD optional
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function GetSystemCpuSetInformation(
Information As IntPtr, ' SYSTEM_CPU_SET_INFORMATION* optional, out
BufferLength As UInteger, ' DWORD
<Out> ByRef ReturnedLength As UInteger, ' DWORD* out
Process As IntPtr, ' HANDLE optional
Flags As UInteger ' DWORD optional
) As Boolean
End Function' Information : SYSTEM_CPU_SET_INFORMATION* optional, out
' BufferLength : DWORD
' ReturnedLength : DWORD* out
' Process : HANDLE optional
' Flags : DWORD optional
Declare PtrSafe Function GetSystemCpuSetInformation Lib "kernel32" ( _
ByVal Information As LongPtr, _
ByVal BufferLength As Long, _
ByRef ReturnedLength As Long, _
ByVal Process As LongPtr, _
ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetSystemCpuSetInformation = ctypes.windll.kernel32.GetSystemCpuSetInformation
GetSystemCpuSetInformation.restype = wintypes.BOOL
GetSystemCpuSetInformation.argtypes = [
ctypes.c_void_p, # Information : SYSTEM_CPU_SET_INFORMATION* optional, out
wintypes.DWORD, # BufferLength : DWORD
ctypes.POINTER(wintypes.DWORD), # ReturnedLength : DWORD* out
wintypes.HANDLE, # Process : HANDLE optional
wintypes.DWORD, # Flags : DWORD optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetSystemCpuSetInformation = Fiddle::Function.new(
lib['GetSystemCpuSetInformation'],
[
Fiddle::TYPE_VOIDP, # Information : SYSTEM_CPU_SET_INFORMATION* optional, out
-Fiddle::TYPE_INT, # BufferLength : DWORD
Fiddle::TYPE_VOIDP, # ReturnedLength : DWORD* out
Fiddle::TYPE_VOIDP, # Process : HANDLE optional
-Fiddle::TYPE_INT, # Flags : DWORD optional
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetSystemCpuSetInformation(
Information: *mut SYSTEM_CPU_SET_INFORMATION, // SYSTEM_CPU_SET_INFORMATION* optional, out
BufferLength: u32, // DWORD
ReturnedLength: *mut u32, // DWORD* out
Process: *mut core::ffi::c_void, // HANDLE optional
Flags: u32 // DWORD optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool GetSystemCpuSetInformation(IntPtr Information, uint BufferLength, out uint ReturnedLength, IntPtr Process, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetSystemCpuSetInformation' -Namespace Win32 -PassThru
# $api::GetSystemCpuSetInformation(Information, BufferLength, ReturnedLength, Process, Flags)#uselib "KERNEL32.dll"
#func global GetSystemCpuSetInformation "GetSystemCpuSetInformation" sptr, sptr, sptr, sptr, sptr
; GetSystemCpuSetInformation varptr(Information), BufferLength, varptr(ReturnedLength), Process, Flags ; 戻り値は stat
; Information : SYSTEM_CPU_SET_INFORMATION* optional, out -> "sptr"
; BufferLength : DWORD -> "sptr"
; ReturnedLength : DWORD* out -> "sptr"
; Process : HANDLE optional -> "sptr"
; Flags : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetSystemCpuSetInformation "GetSystemCpuSetInformation" var, int, var, sptr, int ; res = GetSystemCpuSetInformation(Information, BufferLength, ReturnedLength, Process, Flags) ; Information : SYSTEM_CPU_SET_INFORMATION* optional, out -> "var" ; BufferLength : DWORD -> "int" ; ReturnedLength : DWORD* out -> "var" ; Process : HANDLE optional -> "sptr" ; Flags : DWORD optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetSystemCpuSetInformation "GetSystemCpuSetInformation" sptr, int, sptr, sptr, int ; res = GetSystemCpuSetInformation(varptr(Information), BufferLength, varptr(ReturnedLength), Process, Flags) ; Information : SYSTEM_CPU_SET_INFORMATION* optional, out -> "sptr" ; BufferLength : DWORD -> "int" ; ReturnedLength : DWORD* out -> "sptr" ; Process : HANDLE optional -> "sptr" ; Flags : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetSystemCpuSetInformation(SYSTEM_CPU_SET_INFORMATION* Information, DWORD BufferLength, DWORD* ReturnedLength, HANDLE Process, DWORD Flags) #uselib "KERNEL32.dll" #cfunc global GetSystemCpuSetInformation "GetSystemCpuSetInformation" var, int, var, intptr, int ; res = GetSystemCpuSetInformation(Information, BufferLength, ReturnedLength, Process, Flags) ; Information : SYSTEM_CPU_SET_INFORMATION* optional, out -> "var" ; BufferLength : DWORD -> "int" ; ReturnedLength : DWORD* out -> "var" ; Process : HANDLE optional -> "intptr" ; Flags : DWORD optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetSystemCpuSetInformation(SYSTEM_CPU_SET_INFORMATION* Information, DWORD BufferLength, DWORD* ReturnedLength, HANDLE Process, DWORD Flags) #uselib "KERNEL32.dll" #cfunc global GetSystemCpuSetInformation "GetSystemCpuSetInformation" intptr, int, intptr, intptr, int ; res = GetSystemCpuSetInformation(varptr(Information), BufferLength, varptr(ReturnedLength), Process, Flags) ; Information : SYSTEM_CPU_SET_INFORMATION* optional, out -> "intptr" ; BufferLength : DWORD -> "int" ; ReturnedLength : DWORD* out -> "intptr" ; Process : HANDLE optional -> "intptr" ; Flags : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetSystemCpuSetInformation = kernel32.NewProc("GetSystemCpuSetInformation")
)
// Information (SYSTEM_CPU_SET_INFORMATION* optional, out), BufferLength (DWORD), ReturnedLength (DWORD* out), Process (HANDLE optional), Flags (DWORD optional)
r1, _, err := procGetSystemCpuSetInformation.Call(
uintptr(Information),
uintptr(BufferLength),
uintptr(ReturnedLength),
uintptr(Process),
uintptr(Flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetSystemCpuSetInformation(
Information: Pointer; // SYSTEM_CPU_SET_INFORMATION* optional, out
BufferLength: DWORD; // DWORD
ReturnedLength: Pointer; // DWORD* out
Process: THandle; // HANDLE optional
Flags: DWORD // DWORD optional
): BOOL; stdcall;
external 'KERNEL32.dll' name 'GetSystemCpuSetInformation';result := DllCall("KERNEL32\GetSystemCpuSetInformation"
, "Ptr", Information ; SYSTEM_CPU_SET_INFORMATION* optional, out
, "UInt", BufferLength ; DWORD
, "Ptr", ReturnedLength ; DWORD* out
, "Ptr", Process ; HANDLE optional
, "UInt", Flags ; DWORD optional
, "Int") ; return: BOOL●GetSystemCpuSetInformation(Information, BufferLength, ReturnedLength, Process, Flags) = DLL("KERNEL32.dll", "bool GetSystemCpuSetInformation(void*, dword, void*, void*, dword)")
# 呼び出し: GetSystemCpuSetInformation(Information, BufferLength, ReturnedLength, Process, Flags)
# Information : SYSTEM_CPU_SET_INFORMATION* optional, out -> "void*"
# BufferLength : DWORD -> "dword"
# ReturnedLength : DWORD* out -> "void*"
# Process : HANDLE optional -> "void*"
# Flags : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。