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

GopherFindFirstFileA

関数
Gopherサーバーの項目検索を開始し最初の結果を得る(ANSI版)。
DLLWININET.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

void* GopherFindFirstFileA(
    void* hConnect,
    LPCSTR lpszLocator,   // optional
    LPCSTR lpszSearchString,   // optional
    GOPHER_FIND_DATAA* lpFindData,   // optional
    DWORD dwFlags,
    UINT_PTR dwContext   // optional
);

パラメーター

名前方向
hConnectvoid*in
lpszLocatorLPCSTRinoptional
lpszSearchStringLPCSTRinoptional
lpFindDataGOPHER_FIND_DATAA*outoptional
dwFlagsDWORDin
dwContextUINT_PTRinoptional

戻り値の型: void*

各言語での呼び出し定義

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

void* GopherFindFirstFileA(
    void* hConnect,
    LPCSTR lpszLocator,   // optional
    LPCSTR lpszSearchString,   // optional
    GOPHER_FIND_DATAA* lpFindData,   // optional
    DWORD dwFlags,
    UINT_PTR dwContext   // optional
);
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr GopherFindFirstFileA(
    IntPtr hConnect,   // void*
    [MarshalAs(UnmanagedType.LPStr)] string lpszLocator,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string lpszSearchString,   // LPCSTR optional
    IntPtr lpFindData,   // GOPHER_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 GopherFindFirstFileA(
    hConnect As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPStr)> lpszLocator As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> lpszSearchString As String,   ' LPCSTR optional
    lpFindData As IntPtr,   ' GOPHER_FIND_DATAA* optional, out
    dwFlags As UInteger,   ' DWORD
    dwContext As UIntPtr   ' UINT_PTR optional
) As IntPtr
End Function
' hConnect : void*
' lpszLocator : LPCSTR optional
' lpszSearchString : LPCSTR optional
' lpFindData : GOPHER_FIND_DATAA* optional, out
' dwFlags : DWORD
' dwContext : UINT_PTR optional
Declare PtrSafe Function GopherFindFirstFileA Lib "wininet" ( _
    ByVal hConnect As LongPtr, _
    ByVal lpszLocator As String, _
    ByVal lpszSearchString As String, _
    ByVal lpFindData 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

GopherFindFirstFileA = ctypes.windll.wininet.GopherFindFirstFileA
GopherFindFirstFileA.restype = ctypes.c_void_p
GopherFindFirstFileA.argtypes = [
    ctypes.POINTER(None),  # hConnect : void*
    wintypes.LPCSTR,  # lpszLocator : LPCSTR optional
    wintypes.LPCSTR,  # lpszSearchString : LPCSTR optional
    ctypes.c_void_p,  # lpFindData : GOPHER_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')
GopherFindFirstFileA = Fiddle::Function.new(
  lib['GopherFindFirstFileA'],
  [
    Fiddle::TYPE_VOIDP,  # hConnect : void*
    Fiddle::TYPE_VOIDP,  # lpszLocator : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # lpszSearchString : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # lpFindData : GOPHER_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 GopherFindFirstFileA(
        hConnect: *mut (),  // void*
        lpszLocator: *const u8,  // LPCSTR optional
        lpszSearchString: *const u8,  // LPCSTR optional
        lpFindData: *mut GOPHER_FIND_DATAA,  // GOPHER_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 GopherFindFirstFileA(IntPtr hConnect, [MarshalAs(UnmanagedType.LPStr)] string lpszLocator, [MarshalAs(UnmanagedType.LPStr)] string lpszSearchString, IntPtr lpFindData, uint dwFlags, UIntPtr dwContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_GopherFindFirstFileA' -Namespace Win32 -PassThru
# $api::GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, lpFindData, dwFlags, dwContext)
#uselib "WININET.dll"
#func global GopherFindFirstFileA "GopherFindFirstFileA" sptr, sptr, sptr, sptr, sptr, sptr
; GopherFindFirstFileA hConnect, lpszLocator, lpszSearchString, varptr(lpFindData), dwFlags, dwContext   ; 戻り値は stat
; hConnect : void* -> "sptr"
; lpszLocator : LPCSTR optional -> "sptr"
; lpszSearchString : LPCSTR optional -> "sptr"
; lpFindData : GOPHER_FIND_DATAA* optional, out -> "sptr"
; dwFlags : DWORD -> "sptr"
; dwContext : UINT_PTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global GopherFindFirstFileA "GopherFindFirstFileA" sptr, str, str, var, int, sptr
; res = GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, lpFindData, dwFlags, dwContext)
; hConnect : void* -> "sptr"
; lpszLocator : LPCSTR optional -> "str"
; lpszSearchString : LPCSTR optional -> "str"
; lpFindData : GOPHER_FIND_DATAA* optional, out -> "var"
; dwFlags : DWORD -> "int"
; dwContext : UINT_PTR optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void* GopherFindFirstFileA(void* hConnect, LPCSTR lpszLocator, LPCSTR lpszSearchString, GOPHER_FIND_DATAA* lpFindData, DWORD dwFlags, UINT_PTR dwContext)
#uselib "WININET.dll"
#cfunc global GopherFindFirstFileA "GopherFindFirstFileA" intptr, str, str, var, int, intptr
; res = GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, lpFindData, dwFlags, dwContext)
; hConnect : void* -> "intptr"
; lpszLocator : LPCSTR optional -> "str"
; lpszSearchString : LPCSTR optional -> "str"
; lpFindData : GOPHER_FIND_DATAA* optional, out -> "var"
; dwFlags : DWORD -> "int"
; dwContext : UINT_PTR optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procGopherFindFirstFileA = wininet.NewProc("GopherFindFirstFileA")
)

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