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