ホーム › System.Diagnostics.Debug › SymSetHomeDirectoryW
SymSetHomeDirectoryW
関数シンボルハンドラのホームディレクトリを設定する。
シグネチャ
// dbghelp.dll (Unicode / -W)
#include <windows.h>
LPWSTR SymSetHomeDirectoryW(
HANDLE hProcess, // optional
LPCWSTR dir // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hProcess | HANDLE | inoptional |
| dir | LPCWSTR | inoptional |
戻り値の型: LPWSTR
各言語での呼び出し定義
// dbghelp.dll (Unicode / -W)
#include <windows.h>
LPWSTR SymSetHomeDirectoryW(
HANDLE hProcess, // optional
LPCWSTR dir // optional
);[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr SymSetHomeDirectoryW(
IntPtr hProcess, // HANDLE optional
[MarshalAs(UnmanagedType.LPWStr)] string dir // LPCWSTR optional
);<DllImport("dbghelp.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymSetHomeDirectoryW(
hProcess As IntPtr, ' HANDLE optional
<MarshalAs(UnmanagedType.LPWStr)> dir As String ' LPCWSTR optional
) As IntPtr
End Function' hProcess : HANDLE optional
' dir : LPCWSTR optional
Declare PtrSafe Function SymSetHomeDirectoryW Lib "dbghelp" ( _
ByVal hProcess As LongPtr, _
ByVal dir As LongPtr) As LongPtr
' 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
SymSetHomeDirectoryW = ctypes.windll.dbghelp.SymSetHomeDirectoryW
SymSetHomeDirectoryW.restype = wintypes.LPWSTR
SymSetHomeDirectoryW.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE optional
wintypes.LPCWSTR, # dir : LPCWSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dbghelp.dll')
SymSetHomeDirectoryW = Fiddle::Function.new(
lib['SymSetHomeDirectoryW'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE optional
Fiddle::TYPE_VOIDP, # dir : LPCWSTR optional
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "dbghelp")]
extern "system" {
fn SymSetHomeDirectoryW(
hProcess: *mut core::ffi::c_void, // HANDLE optional
dir: *const u16 // LPCWSTR optional
) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr SymSetHomeDirectoryW(IntPtr hProcess, [MarshalAs(UnmanagedType.LPWStr)] string dir);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymSetHomeDirectoryW' -Namespace Win32 -PassThru
# $api::SymSetHomeDirectoryW(hProcess, dir)#uselib "dbghelp.dll"
#func global SymSetHomeDirectoryW "SymSetHomeDirectoryW" wptr, wptr
; SymSetHomeDirectoryW hProcess, dir ; 戻り値は stat
; hProcess : HANDLE optional -> "wptr"
; dir : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "dbghelp.dll"
#cfunc global SymSetHomeDirectoryW "SymSetHomeDirectoryW" sptr, wstr
; res = SymSetHomeDirectoryW(hProcess, dir)
; hProcess : HANDLE optional -> "sptr"
; dir : LPCWSTR optional -> "wstr"; LPWSTR SymSetHomeDirectoryW(HANDLE hProcess, LPCWSTR dir)
#uselib "dbghelp.dll"
#cfunc global SymSetHomeDirectoryW "SymSetHomeDirectoryW" intptr, wstr
; res = SymSetHomeDirectoryW(hProcess, dir)
; hProcess : HANDLE optional -> "intptr"
; dir : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
procSymSetHomeDirectoryW = dbghelp.NewProc("SymSetHomeDirectoryW")
)
// hProcess (HANDLE optional), dir (LPCWSTR optional)
r1, _, err := procSymSetHomeDirectoryW.Call(
uintptr(hProcess),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(dir))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPWSTRfunction SymSetHomeDirectoryW(
hProcess: THandle; // HANDLE optional
dir: PWideChar // LPCWSTR optional
): PWideChar; stdcall;
external 'dbghelp.dll' name 'SymSetHomeDirectoryW';result := DllCall("dbghelp\SymSetHomeDirectoryW"
, "Ptr", hProcess ; HANDLE optional
, "WStr", dir ; LPCWSTR optional
, "Ptr") ; return: LPWSTR●SymSetHomeDirectoryW(hProcess, dir) = DLL("dbghelp.dll", "char* SymSetHomeDirectoryW(void*, char*)")
# 呼び出し: SymSetHomeDirectoryW(hProcess, dir)
# hProcess : HANDLE optional -> "void*"
# dir : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。