GopherFindFirstFileA
関数シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hConnect | void* | in | InternetConnect によって返される Gopher セッションへのハンドル。 | ||||||||||||
| lpszLocator | LPCSTR | inoptional | 特定する項目の名前を含む null 終端文字列へのポインター。これは次のいずれかになります。
| ||||||||||||
| lpszSearchString | LPCSTR | inoptional | この要求がインデックスサーバーに対するものである場合、検索する文字列を含むバッファーへのポインター。それ以外の場合、このパラメーターは NULL にする必要があります。 | ||||||||||||
| lpFindData | GOPHER_FIND_DATAA* | outoptional | この関数によって取得される情報を受け取る GOPHER_FIND_DATA 構造体へのポインター。 | ||||||||||||
| dwFlags | DWORD | in | 関数の動作を制御します。このパラメーターには、次の値の組み合わせを指定できます。
| ||||||||||||
| dwContext | UINT_PTR | inoptional | この検索を任意のアプリケーションデータと関連付ける、アプリケーション定義の値を含む変数へのポインター。 |
戻り値の型: void*
公式ドキュメント
Gopher ロケーターと検索条件を使用してサーバーとのセッションを作成し、要求されたドキュメント、バイナリファイル、インデックスサーバー、またはディレクトリツリーを特定します。(ANSI)
戻り値
成功した場合は有効な検索ハンドルを返し、それ以外の場合は NULL を返します。拡張エラー情報を取得するには、 GetLastError または InternetGetLastResponseInfo を呼び出します。
解説(Remarks)
GopherFindFirstFile は FindFirstFile 関数とよく似ています。Gopher サーバーとの接続を作成し、ロケーター文字列によって参照される最初の Gopher オブジェクトに関する情報を含む単一の構造体を返します。
列挙内の最初の Gopher オブジェクトを取得するために GopherFindFirstFile を呼び出した後、アプリケーションは InternetFindNextFile 関数を使用して後続の Gopher オブジェクトを取得できます。
呼び出し元のアプリケーションは、 GopherFindFirstFile によって返された HINTERNET ハンドルの使用を終えた後、 InternetCloseHandle 関数を使用してそれを閉じる必要があります。
WinINet API の他のすべての側面と同様に、この関数は DllMain 内やグローバルオブジェクトのコンストラクター・デストラクター内から安全に呼び出すことはできません。
wininet.h ヘッダーは、GopherFindFirstFile を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、コンパイルエラーや実行時エラーを引き起こす不一致につながる可能性があります。詳細については、関数プロトタイプの規約 を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 方式にも切替可。#uselib "WININET.dll" #cfunc global GopherFindFirstFileA "GopherFindFirstFileA" sptr, str, str, sptr, int, sptr ; res = GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, varptr(lpFindData), dwFlags, dwContext) ; hConnect : void* -> "sptr" ; lpszLocator : LPCSTR optional -> "str" ; lpszSearchString : LPCSTR optional -> "str" ; lpFindData : GOPHER_FIND_DATAA* optional, out -> "sptr" ; dwFlags : DWORD -> "int" ; dwContext : UINT_PTR optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, int, intptr ; res = GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, varptr(lpFindData), dwFlags, dwContext) ; hConnect : void* -> "intptr" ; lpszLocator : LPCSTR optional -> "str" ; lpszSearchString : LPCSTR optional -> "str" ; lpFindData : GOPHER_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")
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)。const std = @import("std");
extern "wininet" fn GopherFindFirstFileA(
hConnect: ?*anyopaque, // void*
lpszLocator: [*c]const u8, // LPCSTR optional
lpszSearchString: [*c]const u8, // LPCSTR optional
lpFindData: [*c]GOPHER_FIND_DATAA, // GOPHER_FIND_DATAA* optional, out
dwFlags: u32, // DWORD
dwContext: usize // UINT_PTR optional
) callconv(std.os.windows.WINAPI) ?*anyopaque;proc GopherFindFirstFileA(
hConnect: pointer, # void*
lpszLocator: cstring, # LPCSTR optional
lpszSearchString: cstring, # LPCSTR optional
lpFindData: ptr GOPHER_FIND_DATAA, # GOPHER_FIND_DATAA* optional, out
dwFlags: uint32, # DWORD
dwContext: uint # UINT_PTR optional
): pointer {.importc: "GopherFindFirstFileA", stdcall, dynlib: "WININET.dll".}pragma(lib, "wininet");
extern(Windows)
void* GopherFindFirstFileA(
void* hConnect, // void*
const(char)* lpszLocator, // LPCSTR optional
const(char)* lpszSearchString, // LPCSTR optional
GOPHER_FIND_DATAA* lpFindData, // GOPHER_FIND_DATAA* optional, out
uint dwFlags, // DWORD
size_t dwContext // UINT_PTR optional
);ccall((:GopherFindFirstFileA, "WININET.dll"), stdcall, Ptr{Cvoid},
(Ptr{Cvoid}, Cstring, Cstring, Ptr{GOPHER_FIND_DATAA}, UInt32, Csize_t),
hConnect, lpszLocator, lpszSearchString, lpFindData, dwFlags, dwContext)
# hConnect : void* -> Ptr{Cvoid}
# lpszLocator : LPCSTR optional -> Cstring
# lpszSearchString : LPCSTR optional -> Cstring
# lpFindData : GOPHER_FIND_DATAA* optional, out -> Ptr{GOPHER_FIND_DATAA}
# dwFlags : DWORD -> UInt32
# dwContext : UINT_PTR optional -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* GopherFindFirstFileA(
void* hConnect,
const char* lpszLocator,
const char* lpszSearchString,
void* lpFindData,
uint32_t dwFlags,
uintptr_t dwContext);
]]
local wininet = ffi.load("wininet")
-- wininet.GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, lpFindData, dwFlags, dwContext)
-- hConnect : void*
-- lpszLocator : LPCSTR optional
-- lpszSearchString : LPCSTR optional
-- lpFindData : GOPHER_FIND_DATAA* optional, out
-- dwFlags : DWORD
-- dwContext : UINT_PTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const GopherFindFirstFileA = lib.func('__stdcall', 'GopherFindFirstFileA', 'void *', ['void *', 'str', 'str', 'void *', 'uint32_t', 'uintptr_t']);
// GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, lpFindData, dwFlags, dwContext)
// hConnect : void* -> 'void *'
// lpszLocator : LPCSTR optional -> 'str'
// lpszSearchString : LPCSTR optional -> 'str'
// lpFindData : GOPHER_FIND_DATAA* optional, out -> 'void *'
// dwFlags : DWORD -> 'uint32_t'
// dwContext : UINT_PTR optional -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
GopherFindFirstFileA: { parameters: ["pointer", "buffer", "buffer", "pointer", "u32", "usize"], result: "pointer" },
});
// lib.symbols.GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, lpFindData, dwFlags, dwContext)
// hConnect : void* -> "pointer"
// lpszLocator : LPCSTR optional -> "buffer"
// lpszSearchString : LPCSTR optional -> "buffer"
// lpFindData : GOPHER_FIND_DATAA* optional, out -> "pointer"
// dwFlags : DWORD -> "u32"
// dwContext : UINT_PTR optional -> "usize"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* GopherFindFirstFileA(
void* hConnect,
const char* lpszLocator,
const char* lpszSearchString,
void* lpFindData,
uint32_t dwFlags,
size_t dwContext);
C, "WININET.dll");
// $ffi->GopherFindFirstFileA(hConnect, lpszLocator, lpszSearchString, lpFindData, dwFlags, dwContext);
// hConnect : void*
// lpszLocator : LPCSTR optional
// lpszSearchString : LPCSTR optional
// lpFindData : GOPHER_FIND_DATAA* optional, out
// dwFlags : DWORD
// dwContext : UINT_PTR optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wininet extends StdCallLibrary {
Wininet INSTANCE = Native.load("wininet", Wininet.class, W32APIOptions.ASCII_OPTIONS);
Pointer GopherFindFirstFileA(
Pointer hConnect, // void*
String lpszLocator, // LPCSTR optional
String lpszSearchString, // LPCSTR optional
Pointer lpFindData, // GOPHER_FIND_DATAA* optional, out
int dwFlags, // DWORD
long dwContext // UINT_PTR optional
);
}@[Link("wininet")]
lib LibWININET
fun GopherFindFirstFileA = GopherFindFirstFileA(
hConnect : Void*, # void*
lpszLocator : UInt8*, # LPCSTR optional
lpszSearchString : UInt8*, # LPCSTR optional
lpFindData : GOPHER_FIND_DATAA*, # GOPHER_FIND_DATAA* optional, out
dwFlags : UInt32, # DWORD
dwContext : LibC::SizeT # UINT_PTR optional
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GopherFindFirstFileANative = Pointer<Void> Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Void>, Uint32, UintPtr);
typedef GopherFindFirstFileADart = Pointer<Void> Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Void>, int, int);
final GopherFindFirstFileA = DynamicLibrary.open('WININET.dll')
.lookupFunction<GopherFindFirstFileANative, GopherFindFirstFileADart>('GopherFindFirstFileA');
// hConnect : void* -> Pointer<Void>
// lpszLocator : LPCSTR optional -> Pointer<Utf8>
// lpszSearchString : LPCSTR optional -> Pointer<Utf8>
// lpFindData : GOPHER_FIND_DATAA* optional, out -> Pointer<Void>
// dwFlags : DWORD -> Uint32
// dwContext : UINT_PTR optional -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GopherFindFirstFileA"
c_GopherFindFirstFileA :: Ptr () -> CString -> CString -> Ptr () -> Word32 -> CUIntPtr -> IO (Ptr ())
-- hConnect : void* -> Ptr ()
-- lpszLocator : LPCSTR optional -> CString
-- lpszSearchString : LPCSTR optional -> CString
-- lpFindData : GOPHER_FIND_DATAA* optional, out -> Ptr ()
-- dwFlags : DWORD -> Word32
-- dwContext : UINT_PTR optional -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gopherfindfirstfilea =
foreign "GopherFindFirstFileA"
((ptr void) @-> string @-> string @-> (ptr void) @-> uint32_t @-> size_t @-> returning (ptr void))
(* hConnect : void* -> (ptr void) *)
(* lpszLocator : LPCSTR optional -> string *)
(* lpszSearchString : LPCSTR optional -> string *)
(* lpFindData : GOPHER_FIND_DATAA* optional, out -> (ptr void) *)
(* dwFlags : DWORD -> uint32_t *)
(* dwContext : UINT_PTR optional -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("GopherFindFirstFileA" gopher-find-first-file-a :convention :stdcall) :pointer
(h-connect :pointer) ; void*
(lpsz-locator :string) ; LPCSTR optional
(lpsz-search-string :string) ; LPCSTR optional
(lp-find-data :pointer) ; GOPHER_FIND_DATAA* optional, out
(dw-flags :uint32) ; DWORD
(dw-context :uint64)) ; UINT_PTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GopherFindFirstFileA = Win32::API::More->new('WININET',
'LPVOID GopherFindFirstFileA(LPVOID hConnect, LPCSTR lpszLocator, LPCSTR lpszSearchString, LPVOID lpFindData, DWORD dwFlags, WPARAM dwContext)');
# my $ret = $GopherFindFirstFileA->Call($hConnect, $lpszLocator, $lpszSearchString, $lpFindData, $dwFlags, $dwContext);
# hConnect : void* -> LPVOID
# lpszLocator : LPCSTR optional -> LPCSTR
# lpszSearchString : LPCSTR optional -> LPCSTR
# lpFindData : GOPHER_FIND_DATAA* optional, out -> LPVOID
# dwFlags : DWORD -> DWORD
# dwContext : UINT_PTR optional -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f GopherFindFirstFileW (Unicode版) — Gopherサーバーの項目検索を開始し最初の結果を得る(Unicode版)。