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

WindowsInspectString

関数
別プロセス内のHSTRING内容をコールバック経由で調査する。
DLLapi-ms-win-core-winrt-string-l1-1-0.dll呼出規約winapi対応OSwindows8.0

シグネチャ

// api-ms-win-core-winrt-string-l1-1-0.dll
#include <windows.h>

HRESULT WindowsInspectString(
    UINT_PTR targetHString,
    WORD machine,
    PINSPECT_HSTRING_CALLBACK callback,
    void* context,   // optional
    DWORD* length,
    UINT_PTR* targetStringAddress
);

パラメーター

名前方向
targetHStringUINT_PTRin
machineWORDin
callbackPINSPECT_HSTRING_CALLBACKin
contextvoid*inoptional
lengthDWORD*out
targetStringAddressUINT_PTR*out

戻り値の型: HRESULT

各言語での呼び出し定義

// api-ms-win-core-winrt-string-l1-1-0.dll
#include <windows.h>

HRESULT WindowsInspectString(
    UINT_PTR targetHString,
    WORD machine,
    PINSPECT_HSTRING_CALLBACK callback,
    void* context,   // optional
    DWORD* length,
    UINT_PTR* targetStringAddress
);
[DllImport("api-ms-win-core-winrt-string-l1-1-0.dll", ExactSpelling = true)]
static extern int WindowsInspectString(
    UIntPtr targetHString,   // UINT_PTR
    ushort machine,   // WORD
    IntPtr callback,   // PINSPECT_HSTRING_CALLBACK
    IntPtr context,   // void* optional
    out uint length,   // DWORD* out
    out UIntPtr targetStringAddress   // UINT_PTR* out
);
<DllImport("api-ms-win-core-winrt-string-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function WindowsInspectString(
    targetHString As UIntPtr,   ' UINT_PTR
    machine As UShort,   ' WORD
    callback As IntPtr,   ' PINSPECT_HSTRING_CALLBACK
    context As IntPtr,   ' void* optional
    <Out> ByRef length As UInteger,   ' DWORD* out
    <Out> ByRef targetStringAddress As UIntPtr   ' UINT_PTR* out
) As Integer
End Function
' targetHString : UINT_PTR
' machine : WORD
' callback : PINSPECT_HSTRING_CALLBACK
' context : void* optional
' length : DWORD* out
' targetStringAddress : UINT_PTR* out
Declare PtrSafe Function WindowsInspectString Lib "api-ms-win-core-winrt-string-l1-1-0" ( _
    ByVal targetHString As LongPtr, _
    ByVal machine As Integer, _
    ByVal callback As LongPtr, _
    ByVal context As LongPtr, _
    ByRef length As Long, _
    ByRef targetStringAddress As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WindowsInspectString = ctypes.windll.LoadLibrary("api-ms-win-core-winrt-string-l1-1-0.dll").WindowsInspectString
WindowsInspectString.restype = ctypes.c_int
WindowsInspectString.argtypes = [
    ctypes.c_size_t,  # targetHString : UINT_PTR
    ctypes.c_ushort,  # machine : WORD
    ctypes.c_void_p,  # callback : PINSPECT_HSTRING_CALLBACK
    ctypes.POINTER(None),  # context : void* optional
    ctypes.POINTER(wintypes.DWORD),  # length : DWORD* out
    ctypes.POINTER(ctypes.c_size_t),  # targetStringAddress : UINT_PTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-winrt-string-l1-1-0.dll')
WindowsInspectString = Fiddle::Function.new(
  lib['WindowsInspectString'],
  [
    Fiddle::TYPE_UINTPTR_T,  # targetHString : UINT_PTR
    -Fiddle::TYPE_SHORT,  # machine : WORD
    Fiddle::TYPE_VOIDP,  # callback : PINSPECT_HSTRING_CALLBACK
    Fiddle::TYPE_VOIDP,  # context : void* optional
    Fiddle::TYPE_VOIDP,  # length : DWORD* out
    Fiddle::TYPE_VOIDP,  # targetStringAddress : UINT_PTR* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-winrt-string-l1-1-0")]
extern "system" {
    fn WindowsInspectString(
        targetHString: usize,  // UINT_PTR
        machine: u16,  // WORD
        callback: *const core::ffi::c_void,  // PINSPECT_HSTRING_CALLBACK
        context: *mut (),  // void* optional
        length: *mut u32,  // DWORD* out
        targetStringAddress: *mut usize  // UINT_PTR* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("api-ms-win-core-winrt-string-l1-1-0.dll")]
public static extern int WindowsInspectString(UIntPtr targetHString, ushort machine, IntPtr callback, IntPtr context, out uint length, out UIntPtr targetStringAddress);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-winrt-string-l1-1-0_WindowsInspectString' -Namespace Win32 -PassThru
# $api::WindowsInspectString(targetHString, machine, callback, context, length, targetStringAddress)
#uselib "api-ms-win-core-winrt-string-l1-1-0.dll"
#func global WindowsInspectString "WindowsInspectString" sptr, sptr, sptr, sptr, sptr, sptr
; WindowsInspectString targetHString, machine, callback, context, varptr(length), varptr(targetStringAddress)   ; 戻り値は stat
; targetHString : UINT_PTR -> "sptr"
; machine : WORD -> "sptr"
; callback : PINSPECT_HSTRING_CALLBACK -> "sptr"
; context : void* optional -> "sptr"
; length : DWORD* out -> "sptr"
; targetStringAddress : UINT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "api-ms-win-core-winrt-string-l1-1-0.dll"
#cfunc global WindowsInspectString "WindowsInspectString" sptr, int, sptr, sptr, var, var
; res = WindowsInspectString(targetHString, machine, callback, context, length, targetStringAddress)
; targetHString : UINT_PTR -> "sptr"
; machine : WORD -> "int"
; callback : PINSPECT_HSTRING_CALLBACK -> "sptr"
; context : void* optional -> "sptr"
; length : DWORD* out -> "var"
; targetStringAddress : UINT_PTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WindowsInspectString(UINT_PTR targetHString, WORD machine, PINSPECT_HSTRING_CALLBACK callback, void* context, DWORD* length, UINT_PTR* targetStringAddress)
#uselib "api-ms-win-core-winrt-string-l1-1-0.dll"
#cfunc global WindowsInspectString "WindowsInspectString" intptr, int, intptr, intptr, var, var
; res = WindowsInspectString(targetHString, machine, callback, context, length, targetStringAddress)
; targetHString : UINT_PTR -> "intptr"
; machine : WORD -> "int"
; callback : PINSPECT_HSTRING_CALLBACK -> "intptr"
; context : void* optional -> "intptr"
; length : DWORD* out -> "var"
; targetStringAddress : UINT_PTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_core_winrt_string_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-winrt-string-l1-1-0.dll")
	procWindowsInspectString = api_ms_win_core_winrt_string_l1_1_0.NewProc("WindowsInspectString")
)

// targetHString (UINT_PTR), machine (WORD), callback (PINSPECT_HSTRING_CALLBACK), context (void* optional), length (DWORD* out), targetStringAddress (UINT_PTR* out)
r1, _, err := procWindowsInspectString.Call(
	uintptr(targetHString),
	uintptr(machine),
	uintptr(callback),
	uintptr(context),
	uintptr(length),
	uintptr(targetStringAddress),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WindowsInspectString(
  targetHString: NativeUInt;   // UINT_PTR
  machine: Word;   // WORD
  callback: Pointer;   // PINSPECT_HSTRING_CALLBACK
  context: Pointer;   // void* optional
  length: Pointer;   // DWORD* out
  targetStringAddress: Pointer   // UINT_PTR* out
): Integer; stdcall;
  external 'api-ms-win-core-winrt-string-l1-1-0.dll' name 'WindowsInspectString';
result := DllCall("api-ms-win-core-winrt-string-l1-1-0\WindowsInspectString"
    , "UPtr", targetHString   ; UINT_PTR
    , "UShort", machine   ; WORD
    , "Ptr", callback   ; PINSPECT_HSTRING_CALLBACK
    , "Ptr", context   ; void* optional
    , "Ptr", length   ; DWORD* out
    , "Ptr", targetStringAddress   ; UINT_PTR* out
    , "Int")   ; return: HRESULT
●WindowsInspectString(targetHString, machine, callback, context, length, targetStringAddress) = DLL("api-ms-win-core-winrt-string-l1-1-0.dll", "int WindowsInspectString(int, int, void*, void*, void*, void*)")
# 呼び出し: WindowsInspectString(targetHString, machine, callback, context, length, targetStringAddress)
# targetHString : UINT_PTR -> "int"
# machine : WORD -> "int"
# callback : PINSPECT_HSTRING_CALLBACK -> "void*"
# context : void* optional -> "void*"
# length : DWORD* out -> "void*"
# targetStringAddress : UINT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。