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

GetDeviceIDString

関数
TPMで保護されたデバイスIDを文字列で取得する。
DLLtbs.dll呼出規約winapi

シグネチャ

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

HRESULT GetDeviceIDString(
    LPWSTR pszWindowsAIK,   // optional
    DWORD cchWindowsAIK,
    DWORD* pcchResult,
    BOOL* pfProtectedByTPM   // optional
);

パラメーター

名前方向
pszWindowsAIKLPWSTRoutoptional
cchWindowsAIKDWORDin
pcchResultDWORD*out
pfProtectedByTPMBOOL*outoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT GetDeviceIDString(
    LPWSTR pszWindowsAIK,   // optional
    DWORD cchWindowsAIK,
    DWORD* pcchResult,
    BOOL* pfProtectedByTPM   // optional
);
[DllImport("tbs.dll", ExactSpelling = true)]
static extern int GetDeviceIDString(
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszWindowsAIK,   // LPWSTR optional, out
    uint cchWindowsAIK,   // DWORD
    out uint pcchResult,   // DWORD* out
    IntPtr pfProtectedByTPM   // BOOL* optional, out
);
<DllImport("tbs.dll", ExactSpelling:=True)>
Public Shared Function GetDeviceIDString(
    <MarshalAs(UnmanagedType.LPWStr)> pszWindowsAIK As System.Text.StringBuilder,   ' LPWSTR optional, out
    cchWindowsAIK As UInteger,   ' DWORD
    <Out> ByRef pcchResult As UInteger,   ' DWORD* out
    pfProtectedByTPM As IntPtr   ' BOOL* optional, out
) As Integer
End Function
' pszWindowsAIK : LPWSTR optional, out
' cchWindowsAIK : DWORD
' pcchResult : DWORD* out
' pfProtectedByTPM : BOOL* optional, out
Declare PtrSafe Function GetDeviceIDString Lib "tbs" ( _
    ByVal pszWindowsAIK As LongPtr, _
    ByVal cchWindowsAIK As Long, _
    ByRef pcchResult As Long, _
    ByVal pfProtectedByTPM As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetDeviceIDString = ctypes.windll.tbs.GetDeviceIDString
GetDeviceIDString.restype = ctypes.c_int
GetDeviceIDString.argtypes = [
    wintypes.LPWSTR,  # pszWindowsAIK : LPWSTR optional, out
    wintypes.DWORD,  # cchWindowsAIK : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pcchResult : DWORD* out
    ctypes.c_void_p,  # pfProtectedByTPM : BOOL* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('tbs.dll')
GetDeviceIDString = Fiddle::Function.new(
  lib['GetDeviceIDString'],
  [
    Fiddle::TYPE_VOIDP,  # pszWindowsAIK : LPWSTR optional, out
    -Fiddle::TYPE_INT,  # cchWindowsAIK : DWORD
    Fiddle::TYPE_VOIDP,  # pcchResult : DWORD* out
    Fiddle::TYPE_VOIDP,  # pfProtectedByTPM : BOOL* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "tbs")]
extern "system" {
    fn GetDeviceIDString(
        pszWindowsAIK: *mut u16,  // LPWSTR optional, out
        cchWindowsAIK: u32,  // DWORD
        pcchResult: *mut u32,  // DWORD* out
        pfProtectedByTPM: *mut i32  // BOOL* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("tbs.dll")]
public static extern int GetDeviceIDString([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszWindowsAIK, uint cchWindowsAIK, out uint pcchResult, IntPtr pfProtectedByTPM);
"@
$api = Add-Type -MemberDefinition $sig -Name 'tbs_GetDeviceIDString' -Namespace Win32 -PassThru
# $api::GetDeviceIDString(pszWindowsAIK, cchWindowsAIK, pcchResult, pfProtectedByTPM)
#uselib "tbs.dll"
#func global GetDeviceIDString "GetDeviceIDString" sptr, sptr, sptr, sptr
; GetDeviceIDString varptr(pszWindowsAIK), cchWindowsAIK, varptr(pcchResult), pfProtectedByTPM   ; 戻り値は stat
; pszWindowsAIK : LPWSTR optional, out -> "sptr"
; cchWindowsAIK : DWORD -> "sptr"
; pcchResult : DWORD* out -> "sptr"
; pfProtectedByTPM : BOOL* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "tbs.dll"
#cfunc global GetDeviceIDString "GetDeviceIDString" var, int, var, int
; res = GetDeviceIDString(pszWindowsAIK, cchWindowsAIK, pcchResult, pfProtectedByTPM)
; pszWindowsAIK : LPWSTR optional, out -> "var"
; cchWindowsAIK : DWORD -> "int"
; pcchResult : DWORD* out -> "var"
; pfProtectedByTPM : BOOL* optional, out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT GetDeviceIDString(LPWSTR pszWindowsAIK, DWORD cchWindowsAIK, DWORD* pcchResult, BOOL* pfProtectedByTPM)
#uselib "tbs.dll"
#cfunc global GetDeviceIDString "GetDeviceIDString" var, int, var, int
; res = GetDeviceIDString(pszWindowsAIK, cchWindowsAIK, pcchResult, pfProtectedByTPM)
; pszWindowsAIK : LPWSTR optional, out -> "var"
; cchWindowsAIK : DWORD -> "int"
; pcchResult : DWORD* out -> "var"
; pfProtectedByTPM : BOOL* optional, out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	tbs = windows.NewLazySystemDLL("tbs.dll")
	procGetDeviceIDString = tbs.NewProc("GetDeviceIDString")
)

// pszWindowsAIK (LPWSTR optional, out), cchWindowsAIK (DWORD), pcchResult (DWORD* out), pfProtectedByTPM (BOOL* optional, out)
r1, _, err := procGetDeviceIDString.Call(
	uintptr(pszWindowsAIK),
	uintptr(cchWindowsAIK),
	uintptr(pcchResult),
	uintptr(pfProtectedByTPM),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function GetDeviceIDString(
  pszWindowsAIK: PWideChar;   // LPWSTR optional, out
  cchWindowsAIK: DWORD;   // DWORD
  pcchResult: Pointer;   // DWORD* out
  pfProtectedByTPM: Pointer   // BOOL* optional, out
): Integer; stdcall;
  external 'tbs.dll' name 'GetDeviceIDString';
result := DllCall("tbs\GetDeviceIDString"
    , "Ptr", pszWindowsAIK   ; LPWSTR optional, out
    , "UInt", cchWindowsAIK   ; DWORD
    , "Ptr", pcchResult   ; DWORD* out
    , "Ptr", pfProtectedByTPM   ; BOOL* optional, out
    , "Int")   ; return: HRESULT
●GetDeviceIDString(pszWindowsAIK, cchWindowsAIK, pcchResult, pfProtectedByTPM) = DLL("tbs.dll", "int GetDeviceIDString(char*, dword, void*, void*)")
# 呼び出し: GetDeviceIDString(pszWindowsAIK, cchWindowsAIK, pcchResult, pfProtectedByTPM)
# pszWindowsAIK : LPWSTR optional, out -> "char*"
# cchWindowsAIK : DWORD -> "dword"
# pcchResult : DWORD* out -> "void*"
# pfProtectedByTPM : BOOL* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。