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