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

GetCurrentHwProfileW

関数
現在のハードウェアプロファイル情報を取得する(Unicode版)。
DLLADVAPI32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// ADVAPI32.dll  (Unicode / -W)
#include <windows.h>

BOOL GetCurrentHwProfileW(
    HW_PROFILE_INFOW* lpHwProfileInfo
);

パラメーター

名前方向
lpHwProfileInfoHW_PROFILE_INFOW*out

戻り値の型: BOOL

各言語での呼び出し定義

// ADVAPI32.dll  (Unicode / -W)
#include <windows.h>

BOOL GetCurrentHwProfileW(
    HW_PROFILE_INFOW* lpHwProfileInfo
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool GetCurrentHwProfileW(
    IntPtr lpHwProfileInfo   // HW_PROFILE_INFOW* out
);
<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetCurrentHwProfileW(
    lpHwProfileInfo As IntPtr   ' HW_PROFILE_INFOW* out
) As Boolean
End Function
' lpHwProfileInfo : HW_PROFILE_INFOW* out
Declare PtrSafe Function GetCurrentHwProfileW Lib "advapi32" ( _
    ByVal lpHwProfileInfo As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetCurrentHwProfileW = ctypes.windll.advapi32.GetCurrentHwProfileW
GetCurrentHwProfileW.restype = wintypes.BOOL
GetCurrentHwProfileW.argtypes = [
    ctypes.c_void_p,  # lpHwProfileInfo : HW_PROFILE_INFOW* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
GetCurrentHwProfileW = Fiddle::Function.new(
  lib['GetCurrentHwProfileW'],
  [
    Fiddle::TYPE_VOIDP,  # lpHwProfileInfo : HW_PROFILE_INFOW* out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "advapi32")]
extern "system" {
    fn GetCurrentHwProfileW(
        lpHwProfileInfo: *mut HW_PROFILE_INFOW  // HW_PROFILE_INFOW* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool GetCurrentHwProfileW(IntPtr lpHwProfileInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_GetCurrentHwProfileW' -Namespace Win32 -PassThru
# $api::GetCurrentHwProfileW(lpHwProfileInfo)
#uselib "ADVAPI32.dll"
#func global GetCurrentHwProfileW "GetCurrentHwProfileW" wptr
; GetCurrentHwProfileW varptr(lpHwProfileInfo)   ; 戻り値は stat
; lpHwProfileInfo : HW_PROFILE_INFOW* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ADVAPI32.dll"
#cfunc global GetCurrentHwProfileW "GetCurrentHwProfileW" var
; res = GetCurrentHwProfileW(lpHwProfileInfo)
; lpHwProfileInfo : HW_PROFILE_INFOW* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetCurrentHwProfileW(HW_PROFILE_INFOW* lpHwProfileInfo)
#uselib "ADVAPI32.dll"
#cfunc global GetCurrentHwProfileW "GetCurrentHwProfileW" var
; res = GetCurrentHwProfileW(lpHwProfileInfo)
; lpHwProfileInfo : HW_PROFILE_INFOW* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procGetCurrentHwProfileW = advapi32.NewProc("GetCurrentHwProfileW")
)

// lpHwProfileInfo (HW_PROFILE_INFOW* out)
r1, _, err := procGetCurrentHwProfileW.Call(
	uintptr(lpHwProfileInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetCurrentHwProfileW(
  lpHwProfileInfo: Pointer   // HW_PROFILE_INFOW* out
): BOOL; stdcall;
  external 'ADVAPI32.dll' name 'GetCurrentHwProfileW';
result := DllCall("ADVAPI32\GetCurrentHwProfileW"
    , "Ptr", lpHwProfileInfo   ; HW_PROFILE_INFOW* out
    , "Int")   ; return: BOOL
●GetCurrentHwProfileW(lpHwProfileInfo) = DLL("ADVAPI32.dll", "bool GetCurrentHwProfileW(void*)")
# 呼び出し: GetCurrentHwProfileW(lpHwProfileInfo)
# lpHwProfileInfo : HW_PROFILE_INFOW* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。