ホーム › Networking.WinInet › FtpFindFirstFileA
FtpFindFirstFileA
関数FTPサーバー上のファイル検索を開始し最初の項目を取得する(ANSI版)。
シグネチャ
// WININET.dll (ANSI / -A)
#include <windows.h>
void* FtpFindFirstFileA(
void* hConnect,
LPCSTR lpszSearchFile, // optional
WIN32_FIND_DATAA* lpFindFileData, // optional
DWORD dwFlags,
UINT_PTR dwContext // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hConnect | void* | in |
| lpszSearchFile | LPCSTR | inoptional |
| lpFindFileData | WIN32_FIND_DATAA* | outoptional |
| dwFlags | DWORD | in |
| dwContext | UINT_PTR | inoptional |
戻り値の型: void*
各言語での呼び出し定義
// WININET.dll (ANSI / -A)
#include <windows.h>
void* FtpFindFirstFileA(
void* hConnect,
LPCSTR lpszSearchFile, // optional
WIN32_FIND_DATAA* lpFindFileData, // optional
DWORD dwFlags,
UINT_PTR dwContext // optional
);[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr FtpFindFirstFileA(
IntPtr hConnect, // void*
[MarshalAs(UnmanagedType.LPStr)] string lpszSearchFile, // LPCSTR optional
IntPtr lpFindFileData, // WIN32_FIND_DATAA* optional, out
uint dwFlags, // DWORD
UIntPtr dwContext // UINT_PTR optional
);<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FtpFindFirstFileA(
hConnect As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> lpszSearchFile As String, ' LPCSTR optional
lpFindFileData As IntPtr, ' WIN32_FIND_DATAA* optional, out
dwFlags As UInteger, ' DWORD
dwContext As UIntPtr ' UINT_PTR optional
) As IntPtr
End Function' hConnect : void*
' lpszSearchFile : LPCSTR optional
' lpFindFileData : WIN32_FIND_DATAA* optional, out
' dwFlags : DWORD
' dwContext : UINT_PTR optional
Declare PtrSafe Function FtpFindFirstFileA Lib "wininet" ( _
ByVal hConnect As LongPtr, _
ByVal lpszSearchFile As String, _
ByVal lpFindFileData As LongPtr, _
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
FtpFindFirstFileA = ctypes.windll.wininet.FtpFindFirstFileA
FtpFindFirstFileA.restype = ctypes.c_void_p
FtpFindFirstFileA.argtypes = [
ctypes.POINTER(None), # hConnect : void*
wintypes.LPCSTR, # lpszSearchFile : LPCSTR optional
ctypes.c_void_p, # lpFindFileData : WIN32_FIND_DATAA* optional, out
wintypes.DWORD, # dwFlags : DWORD
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')
FtpFindFirstFileA = Fiddle::Function.new(
lib['FtpFindFirstFileA'],
[
Fiddle::TYPE_VOIDP, # hConnect : void*
Fiddle::TYPE_VOIDP, # lpszSearchFile : LPCSTR optional
Fiddle::TYPE_VOIDP, # lpFindFileData : WIN32_FIND_DATAA* optional, out
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_UINTPTR_T, # dwContext : UINT_PTR optional
],
Fiddle::TYPE_VOIDP)#[link(name = "wininet")]
extern "system" {
fn FtpFindFirstFileA(
hConnect: *mut (), // void*
lpszSearchFile: *const u8, // LPCSTR optional
lpFindFileData: *mut WIN32_FIND_DATAA, // WIN32_FIND_DATAA* optional, out
dwFlags: u32, // DWORD
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 FtpFindFirstFileA(IntPtr hConnect, [MarshalAs(UnmanagedType.LPStr)] string lpszSearchFile, IntPtr lpFindFileData, uint dwFlags, UIntPtr dwContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_FtpFindFirstFileA' -Namespace Win32 -PassThru
# $api::FtpFindFirstFileA(hConnect, lpszSearchFile, lpFindFileData, dwFlags, dwContext)#uselib "WININET.dll"
#func global FtpFindFirstFileA "FtpFindFirstFileA" sptr, sptr, sptr, sptr, sptr
; FtpFindFirstFileA hConnect, lpszSearchFile, varptr(lpFindFileData), dwFlags, dwContext ; 戻り値は stat
; hConnect : void* -> "sptr"
; lpszSearchFile : LPCSTR optional -> "sptr"
; lpFindFileData : WIN32_FIND_DATAA* optional, out -> "sptr"
; dwFlags : DWORD -> "sptr"
; dwContext : UINT_PTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global FtpFindFirstFileA "FtpFindFirstFileA" sptr, str, var, int, sptr ; res = FtpFindFirstFileA(hConnect, lpszSearchFile, lpFindFileData, dwFlags, dwContext) ; hConnect : void* -> "sptr" ; lpszSearchFile : LPCSTR optional -> "str" ; lpFindFileData : WIN32_FIND_DATAA* optional, out -> "var" ; dwFlags : DWORD -> "int" ; dwContext : UINT_PTR optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global FtpFindFirstFileA "FtpFindFirstFileA" sptr, str, sptr, int, sptr ; res = FtpFindFirstFileA(hConnect, lpszSearchFile, varptr(lpFindFileData), dwFlags, dwContext) ; hConnect : void* -> "sptr" ; lpszSearchFile : LPCSTR optional -> "str" ; lpFindFileData : WIN32_FIND_DATAA* optional, out -> "sptr" ; dwFlags : DWORD -> "int" ; dwContext : UINT_PTR optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void* FtpFindFirstFileA(void* hConnect, LPCSTR lpszSearchFile, WIN32_FIND_DATAA* lpFindFileData, DWORD dwFlags, UINT_PTR dwContext) #uselib "WININET.dll" #cfunc global FtpFindFirstFileA "FtpFindFirstFileA" intptr, str, var, int, intptr ; res = FtpFindFirstFileA(hConnect, lpszSearchFile, lpFindFileData, dwFlags, dwContext) ; hConnect : void* -> "intptr" ; lpszSearchFile : LPCSTR optional -> "str" ; lpFindFileData : WIN32_FIND_DATAA* optional, out -> "var" ; dwFlags : DWORD -> "int" ; dwContext : UINT_PTR optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void* FtpFindFirstFileA(void* hConnect, LPCSTR lpszSearchFile, WIN32_FIND_DATAA* lpFindFileData, DWORD dwFlags, UINT_PTR dwContext) #uselib "WININET.dll" #cfunc global FtpFindFirstFileA "FtpFindFirstFileA" intptr, str, intptr, int, intptr ; res = FtpFindFirstFileA(hConnect, lpszSearchFile, varptr(lpFindFileData), dwFlags, dwContext) ; hConnect : void* -> "intptr" ; lpszSearchFile : LPCSTR optional -> "str" ; lpFindFileData : WIN32_FIND_DATAA* optional, out -> "intptr" ; dwFlags : DWORD -> "int" ; dwContext : UINT_PTR optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procFtpFindFirstFileA = wininet.NewProc("FtpFindFirstFileA")
)
// hConnect (void*), lpszSearchFile (LPCSTR optional), lpFindFileData (WIN32_FIND_DATAA* optional, out), dwFlags (DWORD), dwContext (UINT_PTR optional)
r1, _, err := procFtpFindFirstFileA.Call(
uintptr(hConnect),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszSearchFile))),
uintptr(lpFindFileData),
uintptr(dwFlags),
uintptr(dwContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function FtpFindFirstFileA(
hConnect: Pointer; // void*
lpszSearchFile: PAnsiChar; // LPCSTR optional
lpFindFileData: Pointer; // WIN32_FIND_DATAA* optional, out
dwFlags: DWORD; // DWORD
dwContext: NativeUInt // UINT_PTR optional
): Pointer; stdcall;
external 'WININET.dll' name 'FtpFindFirstFileA';result := DllCall("WININET\FtpFindFirstFileA"
, "Ptr", hConnect ; void*
, "AStr", lpszSearchFile ; LPCSTR optional
, "Ptr", lpFindFileData ; WIN32_FIND_DATAA* optional, out
, "UInt", dwFlags ; DWORD
, "UPtr", dwContext ; UINT_PTR optional
, "Ptr") ; return: void*●FtpFindFirstFileA(hConnect, lpszSearchFile, lpFindFileData, dwFlags, dwContext) = DLL("WININET.dll", "void* FtpFindFirstFileA(void*, char*, void*, dword, int)")
# 呼び出し: FtpFindFirstFileA(hConnect, lpszSearchFile, lpFindFileData, dwFlags, dwContext)
# hConnect : void* -> "void*"
# lpszSearchFile : LPCSTR optional -> "char*"
# lpFindFileData : WIN32_FIND_DATAA* optional, out -> "void*"
# dwFlags : DWORD -> "dword"
# dwContext : UINT_PTR optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。