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