ホーム › Networking.WinInet › InternetQueryOptionA
InternetQueryOptionA
関数WinINetハンドルの指定したオプション値を取得する(ANSI)。
シグネチャ
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL InternetQueryOptionA(
void* hInternet, // optional
DWORD dwOption,
void* lpBuffer, // optional
DWORD* lpdwBufferLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInternet | void* | inoptional |
| dwOption | DWORD | in |
| lpBuffer | void* | outoptional |
| lpdwBufferLength | DWORD* | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL InternetQueryOptionA(
void* hInternet, // optional
DWORD dwOption,
void* lpBuffer, // optional
DWORD* lpdwBufferLength
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool InternetQueryOptionA(
IntPtr hInternet, // void* optional
uint dwOption, // DWORD
IntPtr lpBuffer, // void* optional, out
ref uint lpdwBufferLength // DWORD* in/out
);<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function InternetQueryOptionA(
hInternet As IntPtr, ' void* optional
dwOption As UInteger, ' DWORD
lpBuffer As IntPtr, ' void* optional, out
ByRef lpdwBufferLength As UInteger ' DWORD* in/out
) As Boolean
End Function' hInternet : void* optional
' dwOption : DWORD
' lpBuffer : void* optional, out
' lpdwBufferLength : DWORD* in/out
Declare PtrSafe Function InternetQueryOptionA Lib "wininet" ( _
ByVal hInternet As LongPtr, _
ByVal dwOption As Long, _
ByVal lpBuffer As LongPtr, _
ByRef lpdwBufferLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
InternetQueryOptionA = ctypes.windll.wininet.InternetQueryOptionA
InternetQueryOptionA.restype = wintypes.BOOL
InternetQueryOptionA.argtypes = [
ctypes.POINTER(None), # hInternet : void* optional
wintypes.DWORD, # dwOption : DWORD
ctypes.POINTER(None), # lpBuffer : void* optional, out
ctypes.POINTER(wintypes.DWORD), # lpdwBufferLength : DWORD* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
InternetQueryOptionA = Fiddle::Function.new(
lib['InternetQueryOptionA'],
[
Fiddle::TYPE_VOIDP, # hInternet : void* optional
-Fiddle::TYPE_INT, # dwOption : DWORD
Fiddle::TYPE_VOIDP, # lpBuffer : void* optional, out
Fiddle::TYPE_VOIDP, # lpdwBufferLength : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn InternetQueryOptionA(
hInternet: *mut (), // void* optional
dwOption: u32, // DWORD
lpBuffer: *mut (), // void* optional, out
lpdwBufferLength: *mut u32 // DWORD* in/out
) -> 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 InternetQueryOptionA(IntPtr hInternet, uint dwOption, IntPtr lpBuffer, ref uint lpdwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetQueryOptionA' -Namespace Win32 -PassThru
# $api::InternetQueryOptionA(hInternet, dwOption, lpBuffer, lpdwBufferLength)#uselib "WININET.dll"
#func global InternetQueryOptionA "InternetQueryOptionA" sptr, sptr, sptr, sptr
; InternetQueryOptionA hInternet, dwOption, lpBuffer, varptr(lpdwBufferLength) ; 戻り値は stat
; hInternet : void* optional -> "sptr"
; dwOption : DWORD -> "sptr"
; lpBuffer : void* optional, out -> "sptr"
; lpdwBufferLength : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global InternetQueryOptionA "InternetQueryOptionA" sptr, int, sptr, var ; res = InternetQueryOptionA(hInternet, dwOption, lpBuffer, lpdwBufferLength) ; hInternet : void* optional -> "sptr" ; dwOption : DWORD -> "int" ; lpBuffer : void* optional, out -> "sptr" ; lpdwBufferLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global InternetQueryOptionA "InternetQueryOptionA" sptr, int, sptr, sptr ; res = InternetQueryOptionA(hInternet, dwOption, lpBuffer, varptr(lpdwBufferLength)) ; hInternet : void* optional -> "sptr" ; dwOption : DWORD -> "int" ; lpBuffer : void* optional, out -> "sptr" ; lpdwBufferLength : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL InternetQueryOptionA(void* hInternet, DWORD dwOption, void* lpBuffer, DWORD* lpdwBufferLength) #uselib "WININET.dll" #cfunc global InternetQueryOptionA "InternetQueryOptionA" intptr, int, intptr, var ; res = InternetQueryOptionA(hInternet, dwOption, lpBuffer, lpdwBufferLength) ; hInternet : void* optional -> "intptr" ; dwOption : DWORD -> "int" ; lpBuffer : void* optional, out -> "intptr" ; lpdwBufferLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL InternetQueryOptionA(void* hInternet, DWORD dwOption, void* lpBuffer, DWORD* lpdwBufferLength) #uselib "WININET.dll" #cfunc global InternetQueryOptionA "InternetQueryOptionA" intptr, int, intptr, intptr ; res = InternetQueryOptionA(hInternet, dwOption, lpBuffer, varptr(lpdwBufferLength)) ; hInternet : void* optional -> "intptr" ; dwOption : DWORD -> "int" ; lpBuffer : void* optional, out -> "intptr" ; lpdwBufferLength : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procInternetQueryOptionA = wininet.NewProc("InternetQueryOptionA")
)
// hInternet (void* optional), dwOption (DWORD), lpBuffer (void* optional, out), lpdwBufferLength (DWORD* in/out)
r1, _, err := procInternetQueryOptionA.Call(
uintptr(hInternet),
uintptr(dwOption),
uintptr(lpBuffer),
uintptr(lpdwBufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction InternetQueryOptionA(
hInternet: Pointer; // void* optional
dwOption: DWORD; // DWORD
lpBuffer: Pointer; // void* optional, out
lpdwBufferLength: Pointer // DWORD* in/out
): BOOL; stdcall;
external 'WININET.dll' name 'InternetQueryOptionA';result := DllCall("WININET\InternetQueryOptionA"
, "Ptr", hInternet ; void* optional
, "UInt", dwOption ; DWORD
, "Ptr", lpBuffer ; void* optional, out
, "Ptr", lpdwBufferLength ; DWORD* in/out
, "Int") ; return: BOOL●InternetQueryOptionA(hInternet, dwOption, lpBuffer, lpdwBufferLength) = DLL("WININET.dll", "bool InternetQueryOptionA(void*, dword, void*, void*)")
# 呼び出し: InternetQueryOptionA(hInternet, dwOption, lpBuffer, lpdwBufferLength)
# hInternet : void* optional -> "void*"
# dwOption : DWORD -> "dword"
# lpBuffer : void* optional, out -> "void*"
# lpdwBufferLength : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。