ホーム › Networking.WinInet › GopherGetAttributeA
GopherGetAttributeA
関数Gopher項目の属性情報を取得して列挙する(ANSI版)。
シグネチャ
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL GopherGetAttributeA(
void* hConnect,
LPCSTR lpszLocator,
LPCSTR lpszAttributeName, // optional
BYTE* lpBuffer,
DWORD dwBufferLength,
DWORD* lpdwCharactersReturned,
GOPHER_ATTRIBUTE_ENUMERATOR lpfnEnumerator, // optional
UINT_PTR dwContext // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hConnect | void* | in |
| lpszLocator | LPCSTR | in |
| lpszAttributeName | LPCSTR | inoptional |
| lpBuffer | BYTE* | out |
| dwBufferLength | DWORD | in |
| lpdwCharactersReturned | DWORD* | out |
| lpfnEnumerator | GOPHER_ATTRIBUTE_ENUMERATOR | inoptional |
| dwContext | UINT_PTR | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL GopherGetAttributeA(
void* hConnect,
LPCSTR lpszLocator,
LPCSTR lpszAttributeName, // optional
BYTE* lpBuffer,
DWORD dwBufferLength,
DWORD* lpdwCharactersReturned,
GOPHER_ATTRIBUTE_ENUMERATOR lpfnEnumerator, // optional
UINT_PTR dwContext // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool GopherGetAttributeA(
IntPtr hConnect, // void*
[MarshalAs(UnmanagedType.LPStr)] string lpszLocator, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string lpszAttributeName, // LPCSTR optional
IntPtr lpBuffer, // BYTE* out
uint dwBufferLength, // DWORD
out uint lpdwCharactersReturned, // DWORD* out
IntPtr lpfnEnumerator, // GOPHER_ATTRIBUTE_ENUMERATOR optional
UIntPtr dwContext // UINT_PTR optional
);<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GopherGetAttributeA(
hConnect As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> lpszLocator As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> lpszAttributeName As String, ' LPCSTR optional
lpBuffer As IntPtr, ' BYTE* out
dwBufferLength As UInteger, ' DWORD
<Out> ByRef lpdwCharactersReturned As UInteger, ' DWORD* out
lpfnEnumerator As IntPtr, ' GOPHER_ATTRIBUTE_ENUMERATOR optional
dwContext As UIntPtr ' UINT_PTR optional
) As Boolean
End Function' hConnect : void*
' lpszLocator : LPCSTR
' lpszAttributeName : LPCSTR optional
' lpBuffer : BYTE* out
' dwBufferLength : DWORD
' lpdwCharactersReturned : DWORD* out
' lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional
' dwContext : UINT_PTR optional
Declare PtrSafe Function GopherGetAttributeA Lib "wininet" ( _
ByVal hConnect As LongPtr, _
ByVal lpszLocator As String, _
ByVal lpszAttributeName As String, _
ByVal lpBuffer As LongPtr, _
ByVal dwBufferLength As Long, _
ByRef lpdwCharactersReturned As Long, _
ByVal lpfnEnumerator As LongPtr, _
ByVal dwContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GopherGetAttributeA = ctypes.windll.wininet.GopherGetAttributeA
GopherGetAttributeA.restype = wintypes.BOOL
GopherGetAttributeA.argtypes = [
ctypes.POINTER(None), # hConnect : void*
wintypes.LPCSTR, # lpszLocator : LPCSTR
wintypes.LPCSTR, # lpszAttributeName : LPCSTR optional
ctypes.POINTER(ctypes.c_ubyte), # lpBuffer : BYTE* out
wintypes.DWORD, # dwBufferLength : DWORD
ctypes.POINTER(wintypes.DWORD), # lpdwCharactersReturned : DWORD* out
ctypes.c_void_p, # lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional
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')
GopherGetAttributeA = Fiddle::Function.new(
lib['GopherGetAttributeA'],
[
Fiddle::TYPE_VOIDP, # hConnect : void*
Fiddle::TYPE_VOIDP, # lpszLocator : LPCSTR
Fiddle::TYPE_VOIDP, # lpszAttributeName : LPCSTR optional
Fiddle::TYPE_VOIDP, # lpBuffer : BYTE* out
-Fiddle::TYPE_INT, # dwBufferLength : DWORD
Fiddle::TYPE_VOIDP, # lpdwCharactersReturned : DWORD* out
Fiddle::TYPE_VOIDP, # lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional
Fiddle::TYPE_UINTPTR_T, # dwContext : UINT_PTR optional
],
Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn GopherGetAttributeA(
hConnect: *mut (), // void*
lpszLocator: *const u8, // LPCSTR
lpszAttributeName: *const u8, // LPCSTR optional
lpBuffer: *mut u8, // BYTE* out
dwBufferLength: u32, // DWORD
lpdwCharactersReturned: *mut u32, // DWORD* out
lpfnEnumerator: *const core::ffi::c_void, // GOPHER_ATTRIBUTE_ENUMERATOR optional
dwContext: usize // UINT_PTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool GopherGetAttributeA(IntPtr hConnect, [MarshalAs(UnmanagedType.LPStr)] string lpszLocator, [MarshalAs(UnmanagedType.LPStr)] string lpszAttributeName, IntPtr lpBuffer, uint dwBufferLength, out uint lpdwCharactersReturned, IntPtr lpfnEnumerator, UIntPtr dwContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_GopherGetAttributeA' -Namespace Win32 -PassThru
# $api::GopherGetAttributeA(hConnect, lpszLocator, lpszAttributeName, lpBuffer, dwBufferLength, lpdwCharactersReturned, lpfnEnumerator, dwContext)#uselib "WININET.dll"
#func global GopherGetAttributeA "GopherGetAttributeA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GopherGetAttributeA hConnect, lpszLocator, lpszAttributeName, varptr(lpBuffer), dwBufferLength, varptr(lpdwCharactersReturned), lpfnEnumerator, dwContext ; 戻り値は stat
; hConnect : void* -> "sptr"
; lpszLocator : LPCSTR -> "sptr"
; lpszAttributeName : LPCSTR optional -> "sptr"
; lpBuffer : BYTE* out -> "sptr"
; dwBufferLength : DWORD -> "sptr"
; lpdwCharactersReturned : DWORD* out -> "sptr"
; lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional -> "sptr"
; dwContext : UINT_PTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global GopherGetAttributeA "GopherGetAttributeA" sptr, str, str, var, int, var, sptr, sptr ; res = GopherGetAttributeA(hConnect, lpszLocator, lpszAttributeName, lpBuffer, dwBufferLength, lpdwCharactersReturned, lpfnEnumerator, dwContext) ; hConnect : void* -> "sptr" ; lpszLocator : LPCSTR -> "str" ; lpszAttributeName : LPCSTR optional -> "str" ; lpBuffer : BYTE* out -> "var" ; dwBufferLength : DWORD -> "int" ; lpdwCharactersReturned : DWORD* out -> "var" ; lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional -> "sptr" ; dwContext : UINT_PTR optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global GopherGetAttributeA "GopherGetAttributeA" sptr, str, str, sptr, int, sptr, sptr, sptr ; res = GopherGetAttributeA(hConnect, lpszLocator, lpszAttributeName, varptr(lpBuffer), dwBufferLength, varptr(lpdwCharactersReturned), lpfnEnumerator, dwContext) ; hConnect : void* -> "sptr" ; lpszLocator : LPCSTR -> "str" ; lpszAttributeName : LPCSTR optional -> "str" ; lpBuffer : BYTE* out -> "sptr" ; dwBufferLength : DWORD -> "int" ; lpdwCharactersReturned : DWORD* out -> "sptr" ; lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional -> "sptr" ; dwContext : UINT_PTR optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GopherGetAttributeA(void* hConnect, LPCSTR lpszLocator, LPCSTR lpszAttributeName, BYTE* lpBuffer, DWORD dwBufferLength, DWORD* lpdwCharactersReturned, GOPHER_ATTRIBUTE_ENUMERATOR lpfnEnumerator, UINT_PTR dwContext) #uselib "WININET.dll" #cfunc global GopherGetAttributeA "GopherGetAttributeA" intptr, str, str, var, int, var, intptr, intptr ; res = GopherGetAttributeA(hConnect, lpszLocator, lpszAttributeName, lpBuffer, dwBufferLength, lpdwCharactersReturned, lpfnEnumerator, dwContext) ; hConnect : void* -> "intptr" ; lpszLocator : LPCSTR -> "str" ; lpszAttributeName : LPCSTR optional -> "str" ; lpBuffer : BYTE* out -> "var" ; dwBufferLength : DWORD -> "int" ; lpdwCharactersReturned : DWORD* out -> "var" ; lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional -> "intptr" ; dwContext : UINT_PTR optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GopherGetAttributeA(void* hConnect, LPCSTR lpszLocator, LPCSTR lpszAttributeName, BYTE* lpBuffer, DWORD dwBufferLength, DWORD* lpdwCharactersReturned, GOPHER_ATTRIBUTE_ENUMERATOR lpfnEnumerator, UINT_PTR dwContext) #uselib "WININET.dll" #cfunc global GopherGetAttributeA "GopherGetAttributeA" intptr, str, str, intptr, int, intptr, intptr, intptr ; res = GopherGetAttributeA(hConnect, lpszLocator, lpszAttributeName, varptr(lpBuffer), dwBufferLength, varptr(lpdwCharactersReturned), lpfnEnumerator, dwContext) ; hConnect : void* -> "intptr" ; lpszLocator : LPCSTR -> "str" ; lpszAttributeName : LPCSTR optional -> "str" ; lpBuffer : BYTE* out -> "intptr" ; dwBufferLength : DWORD -> "int" ; lpdwCharactersReturned : DWORD* out -> "intptr" ; lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional -> "intptr" ; dwContext : UINT_PTR optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procGopherGetAttributeA = wininet.NewProc("GopherGetAttributeA")
)
// hConnect (void*), lpszLocator (LPCSTR), lpszAttributeName (LPCSTR optional), lpBuffer (BYTE* out), dwBufferLength (DWORD), lpdwCharactersReturned (DWORD* out), lpfnEnumerator (GOPHER_ATTRIBUTE_ENUMERATOR optional), dwContext (UINT_PTR optional)
r1, _, err := procGopherGetAttributeA.Call(
uintptr(hConnect),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszLocator))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszAttributeName))),
uintptr(lpBuffer),
uintptr(dwBufferLength),
uintptr(lpdwCharactersReturned),
uintptr(lpfnEnumerator),
uintptr(dwContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GopherGetAttributeA(
hConnect: Pointer; // void*
lpszLocator: PAnsiChar; // LPCSTR
lpszAttributeName: PAnsiChar; // LPCSTR optional
lpBuffer: Pointer; // BYTE* out
dwBufferLength: DWORD; // DWORD
lpdwCharactersReturned: Pointer; // DWORD* out
lpfnEnumerator: Pointer; // GOPHER_ATTRIBUTE_ENUMERATOR optional
dwContext: NativeUInt // UINT_PTR optional
): BOOL; stdcall;
external 'WININET.dll' name 'GopherGetAttributeA';result := DllCall("WININET\GopherGetAttributeA"
, "Ptr", hConnect ; void*
, "AStr", lpszLocator ; LPCSTR
, "AStr", lpszAttributeName ; LPCSTR optional
, "Ptr", lpBuffer ; BYTE* out
, "UInt", dwBufferLength ; DWORD
, "Ptr", lpdwCharactersReturned ; DWORD* out
, "Ptr", lpfnEnumerator ; GOPHER_ATTRIBUTE_ENUMERATOR optional
, "UPtr", dwContext ; UINT_PTR optional
, "Int") ; return: BOOL●GopherGetAttributeA(hConnect, lpszLocator, lpszAttributeName, lpBuffer, dwBufferLength, lpdwCharactersReturned, lpfnEnumerator, dwContext) = DLL("WININET.dll", "bool GopherGetAttributeA(void*, char*, char*, void*, dword, void*, void*, int)")
# 呼び出し: GopherGetAttributeA(hConnect, lpszLocator, lpszAttributeName, lpBuffer, dwBufferLength, lpdwCharactersReturned, lpfnEnumerator, dwContext)
# hConnect : void* -> "void*"
# lpszLocator : LPCSTR -> "char*"
# lpszAttributeName : LPCSTR optional -> "char*"
# lpBuffer : BYTE* out -> "void*"
# dwBufferLength : DWORD -> "dword"
# lpdwCharactersReturned : DWORD* out -> "void*"
# lpfnEnumerator : GOPHER_ATTRIBUTE_ENUMERATOR optional -> "void*"
# dwContext : UINT_PTR optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。