Win32DeleteFile
関数指定したファイルを削除する。
シグネチャ
// SHELL32.dll
#include <windows.h>
BOOL Win32DeleteFile(
LPCWSTR pszPath
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszPath | LPCWSTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
BOOL Win32DeleteFile(
LPCWSTR pszPath
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern bool Win32DeleteFile(
[MarshalAs(UnmanagedType.LPWStr)] string pszPath // LPCWSTR
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function Win32DeleteFile(
<MarshalAs(UnmanagedType.LPWStr)> pszPath As String ' LPCWSTR
) As Boolean
End Function' pszPath : LPCWSTR
Declare PtrSafe Function Win32DeleteFile Lib "shell32" ( _
ByVal pszPath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
Win32DeleteFile = ctypes.windll.shell32.Win32DeleteFile
Win32DeleteFile.restype = wintypes.BOOL
Win32DeleteFile.argtypes = [
wintypes.LPCWSTR, # pszPath : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
Win32DeleteFile = Fiddle::Function.new(
lib['Win32DeleteFile'],
[
Fiddle::TYPE_VOIDP, # pszPath : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn Win32DeleteFile(
pszPath: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll")]
public static extern bool Win32DeleteFile([MarshalAs(UnmanagedType.LPWStr)] string pszPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_Win32DeleteFile' -Namespace Win32 -PassThru
# $api::Win32DeleteFile(pszPath)#uselib "SHELL32.dll"
#func global Win32DeleteFile "Win32DeleteFile" sptr
; Win32DeleteFile pszPath ; 戻り値は stat
; pszPath : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global Win32DeleteFile "Win32DeleteFile" wstr
; res = Win32DeleteFile(pszPath)
; pszPath : LPCWSTR -> "wstr"; BOOL Win32DeleteFile(LPCWSTR pszPath)
#uselib "SHELL32.dll"
#cfunc global Win32DeleteFile "Win32DeleteFile" wstr
; res = Win32DeleteFile(pszPath)
; pszPath : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procWin32DeleteFile = shell32.NewProc("Win32DeleteFile")
)
// pszPath (LPCWSTR)
r1, _, err := procWin32DeleteFile.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPath))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction Win32DeleteFile(
pszPath: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'SHELL32.dll' name 'Win32DeleteFile';result := DllCall("SHELL32\Win32DeleteFile"
, "WStr", pszPath ; LPCWSTR
, "Int") ; return: BOOL●Win32DeleteFile(pszPath) = DLL("SHELL32.dll", "bool Win32DeleteFile(char*)")
# 呼び出し: Win32DeleteFile(pszPath)
# pszPath : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。