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

FtpPutFileEx

関数
ローカルファイルを拡張オプション付きでFTPサーバーへ送信する。
DLLWININET.dll呼出規約winapi

シグネチャ

// WININET.dll
#include <windows.h>

BOOL FtpPutFileEx(
    void* hFtpSession,
    LPCWSTR lpszLocalFile,
    LPCSTR lpszNewRemoteFile,
    DWORD dwFlags,
    UINT_PTR dwContext   // optional
);

パラメーター

名前方向
hFtpSessionvoid*in
lpszLocalFileLPCWSTRin
lpszNewRemoteFileLPCSTRin
dwFlagsDWORDin
dwContextUINT_PTRinoptional

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll
#include <windows.h>

BOOL FtpPutFileEx(
    void* hFtpSession,
    LPCWSTR lpszLocalFile,
    LPCSTR lpszNewRemoteFile,
    DWORD dwFlags,
    UINT_PTR dwContext   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", ExactSpelling = true)]
static extern bool FtpPutFileEx(
    IntPtr hFtpSession,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string lpszLocalFile,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPStr)] string lpszNewRemoteFile,   // LPCSTR
    uint dwFlags,   // DWORD
    UIntPtr dwContext   // UINT_PTR optional
);
<DllImport("WININET.dll", ExactSpelling:=True)>
Public Shared Function FtpPutFileEx(
    hFtpSession As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> lpszLocalFile As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPStr)> lpszNewRemoteFile As String,   ' LPCSTR
    dwFlags As UInteger,   ' DWORD
    dwContext As UIntPtr   ' UINT_PTR optional
) As Boolean
End Function
' hFtpSession : void*
' lpszLocalFile : LPCWSTR
' lpszNewRemoteFile : LPCSTR
' dwFlags : DWORD
' dwContext : UINT_PTR optional
Declare PtrSafe Function FtpPutFileEx Lib "wininet" ( _
    ByVal hFtpSession As LongPtr, _
    ByVal lpszLocalFile As LongPtr, _
    ByVal lpszNewRemoteFile As String, _
    ByVal dwFlags As Long, _
    ByVal dwContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FtpPutFileEx = ctypes.windll.wininet.FtpPutFileEx
FtpPutFileEx.restype = wintypes.BOOL
FtpPutFileEx.argtypes = [
    ctypes.POINTER(None),  # hFtpSession : void*
    wintypes.LPCWSTR,  # lpszLocalFile : LPCWSTR
    wintypes.LPCSTR,  # lpszNewRemoteFile : LPCSTR
    wintypes.DWORD,  # dwFlags : DWORD
    ctypes.c_size_t,  # dwContext : UINT_PTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
FtpPutFileEx = Fiddle::Function.new(
  lib['FtpPutFileEx'],
  [
    Fiddle::TYPE_VOIDP,  # hFtpSession : void*
    Fiddle::TYPE_VOIDP,  # lpszLocalFile : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpszNewRemoteFile : LPCSTR
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_UINTPTR_T,  # dwContext : UINT_PTR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "wininet")]
extern "system" {
    fn FtpPutFileEx(
        hFtpSession: *mut (),  // void*
        lpszLocalFile: *const u16,  // LPCWSTR
        lpszNewRemoteFile: *const u8,  // LPCSTR
        dwFlags: u32,  // DWORD
        dwContext: usize  // UINT_PTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll")]
public static extern bool FtpPutFileEx(IntPtr hFtpSession, [MarshalAs(UnmanagedType.LPWStr)] string lpszLocalFile, [MarshalAs(UnmanagedType.LPStr)] string lpszNewRemoteFile, uint dwFlags, UIntPtr dwContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_FtpPutFileEx' -Namespace Win32 -PassThru
# $api::FtpPutFileEx(hFtpSession, lpszLocalFile, lpszNewRemoteFile, dwFlags, dwContext)
#uselib "WININET.dll"
#func global FtpPutFileEx "FtpPutFileEx" sptr, sptr, sptr, sptr, sptr
; FtpPutFileEx hFtpSession, lpszLocalFile, lpszNewRemoteFile, dwFlags, dwContext   ; 戻り値は stat
; hFtpSession : void* -> "sptr"
; lpszLocalFile : LPCWSTR -> "sptr"
; lpszNewRemoteFile : LPCSTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; dwContext : UINT_PTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WININET.dll"
#cfunc global FtpPutFileEx "FtpPutFileEx" sptr, wstr, str, int, sptr
; res = FtpPutFileEx(hFtpSession, lpszLocalFile, lpszNewRemoteFile, dwFlags, dwContext)
; hFtpSession : void* -> "sptr"
; lpszLocalFile : LPCWSTR -> "wstr"
; lpszNewRemoteFile : LPCSTR -> "str"
; dwFlags : DWORD -> "int"
; dwContext : UINT_PTR optional -> "sptr"
; BOOL FtpPutFileEx(void* hFtpSession, LPCWSTR lpszLocalFile, LPCSTR lpszNewRemoteFile, DWORD dwFlags, UINT_PTR dwContext)
#uselib "WININET.dll"
#cfunc global FtpPutFileEx "FtpPutFileEx" intptr, wstr, str, int, intptr
; res = FtpPutFileEx(hFtpSession, lpszLocalFile, lpszNewRemoteFile, dwFlags, dwContext)
; hFtpSession : void* -> "intptr"
; lpszLocalFile : LPCWSTR -> "wstr"
; lpszNewRemoteFile : LPCSTR -> "str"
; dwFlags : DWORD -> "int"
; dwContext : UINT_PTR optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procFtpPutFileEx = wininet.NewProc("FtpPutFileEx")
)

// hFtpSession (void*), lpszLocalFile (LPCWSTR), lpszNewRemoteFile (LPCSTR), dwFlags (DWORD), dwContext (UINT_PTR optional)
r1, _, err := procFtpPutFileEx.Call(
	uintptr(hFtpSession),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszLocalFile))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszNewRemoteFile))),
	uintptr(dwFlags),
	uintptr(dwContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function FtpPutFileEx(
  hFtpSession: Pointer;   // void*
  lpszLocalFile: PWideChar;   // LPCWSTR
  lpszNewRemoteFile: PAnsiChar;   // LPCSTR
  dwFlags: DWORD;   // DWORD
  dwContext: NativeUInt   // UINT_PTR optional
): BOOL; stdcall;
  external 'WININET.dll' name 'FtpPutFileEx';
result := DllCall("WININET\FtpPutFileEx"
    , "Ptr", hFtpSession   ; void*
    , "WStr", lpszLocalFile   ; LPCWSTR
    , "AStr", lpszNewRemoteFile   ; LPCSTR
    , "UInt", dwFlags   ; DWORD
    , "UPtr", dwContext   ; UINT_PTR optional
    , "Int")   ; return: BOOL
●FtpPutFileEx(hFtpSession, lpszLocalFile, lpszNewRemoteFile, dwFlags, dwContext) = DLL("WININET.dll", "bool FtpPutFileEx(void*, char*, char*, dword, int)")
# 呼び出し: FtpPutFileEx(hFtpSession, lpszLocalFile, lpszNewRemoteFile, dwFlags, dwContext)
# hFtpSession : void* -> "void*"
# lpszLocalFile : LPCWSTR -> "char*"
# lpszNewRemoteFile : LPCSTR -> "char*"
# dwFlags : DWORD -> "dword"
# dwContext : UINT_PTR optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。