Win32 API 日本語リファレンス
ホームNetworking.WinInet › FtpDeleteFileA

FtpDeleteFileA

関数
FTPサーバー上のファイルを削除する(ANSI版)。
DLLWININET.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL FtpDeleteFileA(
    void* hConnect,
    LPCSTR lpszFileName
);

パラメーター

名前方向
hConnectvoid*in
lpszFileNameLPCSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL FtpDeleteFileA(
    void* hConnect,
    LPCSTR lpszFileName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool FtpDeleteFileA(
    IntPtr hConnect,   // void*
    [MarshalAs(UnmanagedType.LPStr)] string lpszFileName   // LPCSTR
);
<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FtpDeleteFileA(
    hConnect As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPStr)> lpszFileName As String   ' LPCSTR
) As Boolean
End Function
' hConnect : void*
' lpszFileName : LPCSTR
Declare PtrSafe Function FtpDeleteFileA Lib "wininet" ( _
    ByVal hConnect As LongPtr, _
    ByVal lpszFileName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FtpDeleteFileA = ctypes.windll.wininet.FtpDeleteFileA
FtpDeleteFileA.restype = wintypes.BOOL
FtpDeleteFileA.argtypes = [
    ctypes.POINTER(None),  # hConnect : void*
    wintypes.LPCSTR,  # lpszFileName : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
FtpDeleteFileA = Fiddle::Function.new(
  lib['FtpDeleteFileA'],
  [
    Fiddle::TYPE_VOIDP,  # hConnect : void*
    Fiddle::TYPE_VOIDP,  # lpszFileName : LPCSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "wininet")]
extern "system" {
    fn FtpDeleteFileA(
        hConnect: *mut (),  // void*
        lpszFileName: *const u8  // LPCSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool FtpDeleteFileA(IntPtr hConnect, [MarshalAs(UnmanagedType.LPStr)] string lpszFileName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_FtpDeleteFileA' -Namespace Win32 -PassThru
# $api::FtpDeleteFileA(hConnect, lpszFileName)
#uselib "WININET.dll"
#func global FtpDeleteFileA "FtpDeleteFileA" sptr, sptr
; FtpDeleteFileA hConnect, lpszFileName   ; 戻り値は stat
; hConnect : void* -> "sptr"
; lpszFileName : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WININET.dll"
#cfunc global FtpDeleteFileA "FtpDeleteFileA" sptr, str
; res = FtpDeleteFileA(hConnect, lpszFileName)
; hConnect : void* -> "sptr"
; lpszFileName : LPCSTR -> "str"
; BOOL FtpDeleteFileA(void* hConnect, LPCSTR lpszFileName)
#uselib "WININET.dll"
#cfunc global FtpDeleteFileA "FtpDeleteFileA" intptr, str
; res = FtpDeleteFileA(hConnect, lpszFileName)
; hConnect : void* -> "intptr"
; lpszFileName : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procFtpDeleteFileA = wininet.NewProc("FtpDeleteFileA")
)

// hConnect (void*), lpszFileName (LPCSTR)
r1, _, err := procFtpDeleteFileA.Call(
	uintptr(hConnect),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszFileName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function FtpDeleteFileA(
  hConnect: Pointer;   // void*
  lpszFileName: PAnsiChar   // LPCSTR
): BOOL; stdcall;
  external 'WININET.dll' name 'FtpDeleteFileA';
result := DllCall("WININET\FtpDeleteFileA"
    , "Ptr", hConnect   ; void*
    , "AStr", lpszFileName   ; LPCSTR
    , "Int")   ; return: BOOL
●FtpDeleteFileA(hConnect, lpszFileName) = DLL("WININET.dll", "bool FtpDeleteFileA(void*, char*)")
# 呼び出し: FtpDeleteFileA(hConnect, lpszFileName)
# hConnect : void* -> "void*"
# lpszFileName : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。