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