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

DelNodeW

関数
指定したファイルまたはディレクトリを削除する(Unicode版)。
DLLADVPACK.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// ADVPACK.dll  (Unicode / -W)
#include <windows.h>

HRESULT DelNodeW(
    LPCWSTR pszFileOrDirName,
    DWORD dwFlags
);

パラメーター

名前方向
pszFileOrDirNameLPCWSTRin
dwFlagsDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

// ADVPACK.dll  (Unicode / -W)
#include <windows.h>

HRESULT DelNodeW(
    LPCWSTR pszFileOrDirName,
    DWORD dwFlags
);
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int DelNodeW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszFileOrDirName,   // LPCWSTR
    uint dwFlags   // DWORD
);
<DllImport("ADVPACK.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DelNodeW(
    <MarshalAs(UnmanagedType.LPWStr)> pszFileOrDirName As String,   ' LPCWSTR
    dwFlags As UInteger   ' DWORD
) As Integer
End Function
' pszFileOrDirName : LPCWSTR
' dwFlags : DWORD
Declare PtrSafe Function DelNodeW Lib "advpack" ( _
    ByVal pszFileOrDirName As LongPtr, _
    ByVal dwFlags 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

DelNodeW = ctypes.windll.advpack.DelNodeW
DelNodeW.restype = ctypes.c_int
DelNodeW.argtypes = [
    wintypes.LPCWSTR,  # pszFileOrDirName : LPCWSTR
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVPACK.dll')
DelNodeW = Fiddle::Function.new(
  lib['DelNodeW'],
  [
    Fiddle::TYPE_VOIDP,  # pszFileOrDirName : LPCWSTR
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "advpack")]
extern "system" {
    fn DelNodeW(
        pszFileOrDirName: *const u16,  // LPCWSTR
        dwFlags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode)]
public static extern int DelNodeW([MarshalAs(UnmanagedType.LPWStr)] string pszFileOrDirName, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_DelNodeW' -Namespace Win32 -PassThru
# $api::DelNodeW(pszFileOrDirName, dwFlags)
#uselib "ADVPACK.dll"
#func global DelNodeW "DelNodeW" wptr, wptr
; DelNodeW pszFileOrDirName, dwFlags   ; 戻り値は stat
; pszFileOrDirName : LPCWSTR -> "wptr"
; dwFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVPACK.dll"
#cfunc global DelNodeW "DelNodeW" wstr, int
; res = DelNodeW(pszFileOrDirName, dwFlags)
; pszFileOrDirName : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; HRESULT DelNodeW(LPCWSTR pszFileOrDirName, DWORD dwFlags)
#uselib "ADVPACK.dll"
#cfunc global DelNodeW "DelNodeW" wstr, int
; res = DelNodeW(pszFileOrDirName, dwFlags)
; pszFileOrDirName : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advpack = windows.NewLazySystemDLL("ADVPACK.dll")
	procDelNodeW = advpack.NewProc("DelNodeW")
)

// pszFileOrDirName (LPCWSTR), dwFlags (DWORD)
r1, _, err := procDelNodeW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFileOrDirName))),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DelNodeW(
  pszFileOrDirName: PWideChar;   // LPCWSTR
  dwFlags: DWORD   // DWORD
): Integer; stdcall;
  external 'ADVPACK.dll' name 'DelNodeW';
result := DllCall("ADVPACK\DelNodeW"
    , "WStr", pszFileOrDirName   ; LPCWSTR
    , "UInt", dwFlags   ; DWORD
    , "Int")   ; return: HRESULT
●DelNodeW(pszFileOrDirName, dwFlags) = DLL("ADVPACK.dll", "int DelNodeW(char*, dword)")
# 呼び出し: DelNodeW(pszFileOrDirName, dwFlags)
# pszFileOrDirName : LPCWSTR -> "char*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。