ホーム › Networking.WinInet › FtpOpenFileA
FtpOpenFileA
関数FTPサーバー上のファイルを読み書き用に開く(ANSI版)。
シグネチャ
// WININET.dll (ANSI / -A)
#include <windows.h>
void* FtpOpenFileA(
void* hConnect,
LPCSTR lpszFileName,
DWORD dwAccess,
FTP_FLAGS dwFlags,
UINT_PTR dwContext // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hConnect | void* | in |
| lpszFileName | LPCSTR | in |
| dwAccess | DWORD | in |
| dwFlags | FTP_FLAGS | in |
| dwContext | UINT_PTR | inoptional |
戻り値の型: void*
各言語での呼び出し定義
// WININET.dll (ANSI / -A)
#include <windows.h>
void* FtpOpenFileA(
void* hConnect,
LPCSTR lpszFileName,
DWORD dwAccess,
FTP_FLAGS dwFlags,
UINT_PTR dwContext // optional
);[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr FtpOpenFileA(
IntPtr hConnect, // void*
[MarshalAs(UnmanagedType.LPStr)] string lpszFileName, // LPCSTR
uint dwAccess, // DWORD
uint dwFlags, // FTP_FLAGS
UIntPtr dwContext // UINT_PTR optional
);<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FtpOpenFileA(
hConnect As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> lpszFileName As String, ' LPCSTR
dwAccess As UInteger, ' DWORD
dwFlags As UInteger, ' FTP_FLAGS
dwContext As UIntPtr ' UINT_PTR optional
) As IntPtr
End Function' hConnect : void*
' lpszFileName : LPCSTR
' dwAccess : DWORD
' dwFlags : FTP_FLAGS
' dwContext : UINT_PTR optional
Declare PtrSafe Function FtpOpenFileA Lib "wininet" ( _
ByVal hConnect As LongPtr, _
ByVal lpszFileName As String, _
ByVal dwAccess As Long, _
ByVal dwFlags As Long, _
ByVal dwContext As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FtpOpenFileA = ctypes.windll.wininet.FtpOpenFileA
FtpOpenFileA.restype = ctypes.c_void_p
FtpOpenFileA.argtypes = [
ctypes.POINTER(None), # hConnect : void*
wintypes.LPCSTR, # lpszFileName : LPCSTR
wintypes.DWORD, # dwAccess : DWORD
wintypes.DWORD, # dwFlags : FTP_FLAGS
ctypes.c_size_t, # dwContext : UINT_PTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
FtpOpenFileA = Fiddle::Function.new(
lib['FtpOpenFileA'],
[
Fiddle::TYPE_VOIDP, # hConnect : void*
Fiddle::TYPE_VOIDP, # lpszFileName : LPCSTR
-Fiddle::TYPE_INT, # dwAccess : DWORD
-Fiddle::TYPE_INT, # dwFlags : FTP_FLAGS
Fiddle::TYPE_UINTPTR_T, # dwContext : UINT_PTR optional
],
Fiddle::TYPE_VOIDP)#[link(name = "wininet")]
extern "system" {
fn FtpOpenFileA(
hConnect: *mut (), // void*
lpszFileName: *const u8, // LPCSTR
dwAccess: u32, // DWORD
dwFlags: u32, // FTP_FLAGS
dwContext: usize // UINT_PTR optional
) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr FtpOpenFileA(IntPtr hConnect, [MarshalAs(UnmanagedType.LPStr)] string lpszFileName, uint dwAccess, uint dwFlags, UIntPtr dwContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_FtpOpenFileA' -Namespace Win32 -PassThru
# $api::FtpOpenFileA(hConnect, lpszFileName, dwAccess, dwFlags, dwContext)#uselib "WININET.dll"
#func global FtpOpenFileA "FtpOpenFileA" sptr, sptr, sptr, sptr, sptr
; FtpOpenFileA hConnect, lpszFileName, dwAccess, dwFlags, dwContext ; 戻り値は stat
; hConnect : void* -> "sptr"
; lpszFileName : LPCSTR -> "sptr"
; dwAccess : DWORD -> "sptr"
; dwFlags : FTP_FLAGS -> "sptr"
; dwContext : UINT_PTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WININET.dll"
#cfunc global FtpOpenFileA "FtpOpenFileA" sptr, str, int, int, sptr
; res = FtpOpenFileA(hConnect, lpszFileName, dwAccess, dwFlags, dwContext)
; hConnect : void* -> "sptr"
; lpszFileName : LPCSTR -> "str"
; dwAccess : DWORD -> "int"
; dwFlags : FTP_FLAGS -> "int"
; dwContext : UINT_PTR optional -> "sptr"; void* FtpOpenFileA(void* hConnect, LPCSTR lpszFileName, DWORD dwAccess, FTP_FLAGS dwFlags, UINT_PTR dwContext)
#uselib "WININET.dll"
#cfunc global FtpOpenFileA "FtpOpenFileA" intptr, str, int, int, intptr
; res = FtpOpenFileA(hConnect, lpszFileName, dwAccess, dwFlags, dwContext)
; hConnect : void* -> "intptr"
; lpszFileName : LPCSTR -> "str"
; dwAccess : DWORD -> "int"
; dwFlags : FTP_FLAGS -> "int"
; dwContext : UINT_PTR optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procFtpOpenFileA = wininet.NewProc("FtpOpenFileA")
)
// hConnect (void*), lpszFileName (LPCSTR), dwAccess (DWORD), dwFlags (FTP_FLAGS), dwContext (UINT_PTR optional)
r1, _, err := procFtpOpenFileA.Call(
uintptr(hConnect),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszFileName))),
uintptr(dwAccess),
uintptr(dwFlags),
uintptr(dwContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function FtpOpenFileA(
hConnect: Pointer; // void*
lpszFileName: PAnsiChar; // LPCSTR
dwAccess: DWORD; // DWORD
dwFlags: DWORD; // FTP_FLAGS
dwContext: NativeUInt // UINT_PTR optional
): Pointer; stdcall;
external 'WININET.dll' name 'FtpOpenFileA';result := DllCall("WININET\FtpOpenFileA"
, "Ptr", hConnect ; void*
, "AStr", lpszFileName ; LPCSTR
, "UInt", dwAccess ; DWORD
, "UInt", dwFlags ; FTP_FLAGS
, "UPtr", dwContext ; UINT_PTR optional
, "Ptr") ; return: void*●FtpOpenFileA(hConnect, lpszFileName, dwAccess, dwFlags, dwContext) = DLL("WININET.dll", "void* FtpOpenFileA(void*, char*, dword, dword, int)")
# 呼び出し: FtpOpenFileA(hConnect, lpszFileName, dwAccess, dwFlags, dwContext)
# hConnect : void* -> "void*"
# lpszFileName : LPCSTR -> "char*"
# dwAccess : DWORD -> "dword"
# dwFlags : FTP_FLAGS -> "dword"
# dwContext : UINT_PTR optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。