ホーム › System.TpmBaseServices › Tbsip_Submit_Command
Tbsip_Submit_Command
関数TPMにコマンドを送信し、結果を受け取る。
シグネチャ
// tbs.dll
#include <windows.h>
DWORD Tbsip_Submit_Command(
void* hContext,
TBS_COMMAND_LOCALITY Locality,
TBS_COMMAND_PRIORITY Priority,
BYTE* pabCommand,
DWORD cbCommand,
BYTE* pabResult,
DWORD* pcbResult
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hContext | void* | in |
| Locality | TBS_COMMAND_LOCALITY | in |
| Priority | TBS_COMMAND_PRIORITY | in |
| pabCommand | BYTE* | in |
| cbCommand | DWORD | in |
| pabResult | BYTE* | out |
| pcbResult | DWORD* | inout |
戻り値の型: DWORD
各言語での呼び出し定義
// tbs.dll
#include <windows.h>
DWORD Tbsip_Submit_Command(
void* hContext,
TBS_COMMAND_LOCALITY Locality,
TBS_COMMAND_PRIORITY Priority,
BYTE* pabCommand,
DWORD cbCommand,
BYTE* pabResult,
DWORD* pcbResult
);[DllImport("tbs.dll", ExactSpelling = true)]
static extern uint Tbsip_Submit_Command(
IntPtr hContext, // void*
uint Locality, // TBS_COMMAND_LOCALITY
uint Priority, // TBS_COMMAND_PRIORITY
IntPtr pabCommand, // BYTE*
uint cbCommand, // DWORD
IntPtr pabResult, // BYTE* out
ref uint pcbResult // DWORD* in/out
);<DllImport("tbs.dll", ExactSpelling:=True)>
Public Shared Function Tbsip_Submit_Command(
hContext As IntPtr, ' void*
Locality As UInteger, ' TBS_COMMAND_LOCALITY
Priority As UInteger, ' TBS_COMMAND_PRIORITY
pabCommand As IntPtr, ' BYTE*
cbCommand As UInteger, ' DWORD
pabResult As IntPtr, ' BYTE* out
ByRef pcbResult As UInteger ' DWORD* in/out
) As UInteger
End Function' hContext : void*
' Locality : TBS_COMMAND_LOCALITY
' Priority : TBS_COMMAND_PRIORITY
' pabCommand : BYTE*
' cbCommand : DWORD
' pabResult : BYTE* out
' pcbResult : DWORD* in/out
Declare PtrSafe Function Tbsip_Submit_Command Lib "tbs" ( _
ByVal hContext As LongPtr, _
ByVal Locality As Long, _
ByVal Priority As Long, _
ByVal pabCommand As LongPtr, _
ByVal cbCommand As Long, _
ByVal pabResult As LongPtr, _
ByRef pcbResult As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
Tbsip_Submit_Command = ctypes.windll.tbs.Tbsip_Submit_Command
Tbsip_Submit_Command.restype = wintypes.DWORD
Tbsip_Submit_Command.argtypes = [
ctypes.POINTER(None), # hContext : void*
wintypes.DWORD, # Locality : TBS_COMMAND_LOCALITY
wintypes.DWORD, # Priority : TBS_COMMAND_PRIORITY
ctypes.POINTER(ctypes.c_ubyte), # pabCommand : BYTE*
wintypes.DWORD, # cbCommand : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pabResult : BYTE* out
ctypes.POINTER(wintypes.DWORD), # pcbResult : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('tbs.dll')
Tbsip_Submit_Command = Fiddle::Function.new(
lib['Tbsip_Submit_Command'],
[
Fiddle::TYPE_VOIDP, # hContext : void*
-Fiddle::TYPE_INT, # Locality : TBS_COMMAND_LOCALITY
-Fiddle::TYPE_INT, # Priority : TBS_COMMAND_PRIORITY
Fiddle::TYPE_VOIDP, # pabCommand : BYTE*
-Fiddle::TYPE_INT, # cbCommand : DWORD
Fiddle::TYPE_VOIDP, # pabResult : BYTE* out
Fiddle::TYPE_VOIDP, # pcbResult : DWORD* in/out
],
-Fiddle::TYPE_INT)#[link(name = "tbs")]
extern "system" {
fn Tbsip_Submit_Command(
hContext: *mut (), // void*
Locality: u32, // TBS_COMMAND_LOCALITY
Priority: u32, // TBS_COMMAND_PRIORITY
pabCommand: *mut u8, // BYTE*
cbCommand: u32, // DWORD
pabResult: *mut u8, // BYTE* out
pcbResult: *mut u32 // DWORD* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("tbs.dll")]
public static extern uint Tbsip_Submit_Command(IntPtr hContext, uint Locality, uint Priority, IntPtr pabCommand, uint cbCommand, IntPtr pabResult, ref uint pcbResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'tbs_Tbsip_Submit_Command' -Namespace Win32 -PassThru
# $api::Tbsip_Submit_Command(hContext, Locality, Priority, pabCommand, cbCommand, pabResult, pcbResult)#uselib "tbs.dll"
#func global Tbsip_Submit_Command "Tbsip_Submit_Command" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; Tbsip_Submit_Command hContext, Locality, Priority, varptr(pabCommand), cbCommand, varptr(pabResult), varptr(pcbResult) ; 戻り値は stat
; hContext : void* -> "sptr"
; Locality : TBS_COMMAND_LOCALITY -> "sptr"
; Priority : TBS_COMMAND_PRIORITY -> "sptr"
; pabCommand : BYTE* -> "sptr"
; cbCommand : DWORD -> "sptr"
; pabResult : BYTE* out -> "sptr"
; pcbResult : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "tbs.dll" #cfunc global Tbsip_Submit_Command "Tbsip_Submit_Command" sptr, int, int, var, int, var, var ; res = Tbsip_Submit_Command(hContext, Locality, Priority, pabCommand, cbCommand, pabResult, pcbResult) ; hContext : void* -> "sptr" ; Locality : TBS_COMMAND_LOCALITY -> "int" ; Priority : TBS_COMMAND_PRIORITY -> "int" ; pabCommand : BYTE* -> "var" ; cbCommand : DWORD -> "int" ; pabResult : BYTE* out -> "var" ; pcbResult : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "tbs.dll" #cfunc global Tbsip_Submit_Command "Tbsip_Submit_Command" sptr, int, int, sptr, int, sptr, sptr ; res = Tbsip_Submit_Command(hContext, Locality, Priority, varptr(pabCommand), cbCommand, varptr(pabResult), varptr(pcbResult)) ; hContext : void* -> "sptr" ; Locality : TBS_COMMAND_LOCALITY -> "int" ; Priority : TBS_COMMAND_PRIORITY -> "int" ; pabCommand : BYTE* -> "sptr" ; cbCommand : DWORD -> "int" ; pabResult : BYTE* out -> "sptr" ; pcbResult : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD Tbsip_Submit_Command(void* hContext, TBS_COMMAND_LOCALITY Locality, TBS_COMMAND_PRIORITY Priority, BYTE* pabCommand, DWORD cbCommand, BYTE* pabResult, DWORD* pcbResult) #uselib "tbs.dll" #cfunc global Tbsip_Submit_Command "Tbsip_Submit_Command" intptr, int, int, var, int, var, var ; res = Tbsip_Submit_Command(hContext, Locality, Priority, pabCommand, cbCommand, pabResult, pcbResult) ; hContext : void* -> "intptr" ; Locality : TBS_COMMAND_LOCALITY -> "int" ; Priority : TBS_COMMAND_PRIORITY -> "int" ; pabCommand : BYTE* -> "var" ; cbCommand : DWORD -> "int" ; pabResult : BYTE* out -> "var" ; pcbResult : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD Tbsip_Submit_Command(void* hContext, TBS_COMMAND_LOCALITY Locality, TBS_COMMAND_PRIORITY Priority, BYTE* pabCommand, DWORD cbCommand, BYTE* pabResult, DWORD* pcbResult) #uselib "tbs.dll" #cfunc global Tbsip_Submit_Command "Tbsip_Submit_Command" intptr, int, int, intptr, int, intptr, intptr ; res = Tbsip_Submit_Command(hContext, Locality, Priority, varptr(pabCommand), cbCommand, varptr(pabResult), varptr(pcbResult)) ; hContext : void* -> "intptr" ; Locality : TBS_COMMAND_LOCALITY -> "int" ; Priority : TBS_COMMAND_PRIORITY -> "int" ; pabCommand : BYTE* -> "intptr" ; cbCommand : DWORD -> "int" ; pabResult : BYTE* out -> "intptr" ; pcbResult : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tbs = windows.NewLazySystemDLL("tbs.dll")
procTbsip_Submit_Command = tbs.NewProc("Tbsip_Submit_Command")
)
// hContext (void*), Locality (TBS_COMMAND_LOCALITY), Priority (TBS_COMMAND_PRIORITY), pabCommand (BYTE*), cbCommand (DWORD), pabResult (BYTE* out), pcbResult (DWORD* in/out)
r1, _, err := procTbsip_Submit_Command.Call(
uintptr(hContext),
uintptr(Locality),
uintptr(Priority),
uintptr(pabCommand),
uintptr(cbCommand),
uintptr(pabResult),
uintptr(pcbResult),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction Tbsip_Submit_Command(
hContext: Pointer; // void*
Locality: DWORD; // TBS_COMMAND_LOCALITY
Priority: DWORD; // TBS_COMMAND_PRIORITY
pabCommand: Pointer; // BYTE*
cbCommand: DWORD; // DWORD
pabResult: Pointer; // BYTE* out
pcbResult: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'tbs.dll' name 'Tbsip_Submit_Command';result := DllCall("tbs\Tbsip_Submit_Command"
, "Ptr", hContext ; void*
, "UInt", Locality ; TBS_COMMAND_LOCALITY
, "UInt", Priority ; TBS_COMMAND_PRIORITY
, "Ptr", pabCommand ; BYTE*
, "UInt", cbCommand ; DWORD
, "Ptr", pabResult ; BYTE* out
, "Ptr", pcbResult ; DWORD* in/out
, "UInt") ; return: DWORD●Tbsip_Submit_Command(hContext, Locality, Priority, pabCommand, cbCommand, pabResult, pcbResult) = DLL("tbs.dll", "dword Tbsip_Submit_Command(void*, dword, dword, void*, dword, void*, void*)")
# 呼び出し: Tbsip_Submit_Command(hContext, Locality, Priority, pabCommand, cbCommand, pabResult, pcbResult)
# hContext : void* -> "void*"
# Locality : TBS_COMMAND_LOCALITY -> "dword"
# Priority : TBS_COMMAND_PRIORITY -> "dword"
# pabCommand : BYTE* -> "void*"
# cbCommand : DWORD -> "dword"
# pabResult : BYTE* out -> "void*"
# pcbResult : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。