ホーム › Networking.WinHttp › WinHttpGetProxyForUrlEx2
WinHttpGetProxyForUrlEx2
関数指定URLのプロキシ情報をインターフェイス指定で非同期取得する。
シグネチャ
// WINHTTP.dll
#include <windows.h>
DWORD WinHttpGetProxyForUrlEx2(
void* hResolver,
LPCWSTR pcwszUrl,
WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions,
DWORD cbInterfaceSelectionContext,
BYTE* pInterfaceSelectionContext, // optional
UINT_PTR pContext // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hResolver | void* | in |
| pcwszUrl | LPCWSTR | in |
| pAutoProxyOptions | WINHTTP_AUTOPROXY_OPTIONS* | in |
| cbInterfaceSelectionContext | DWORD | in |
| pInterfaceSelectionContext | BYTE* | inoptional |
| pContext | UINT_PTR | inoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// WINHTTP.dll
#include <windows.h>
DWORD WinHttpGetProxyForUrlEx2(
void* hResolver,
LPCWSTR pcwszUrl,
WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions,
DWORD cbInterfaceSelectionContext,
BYTE* pInterfaceSelectionContext, // optional
UINT_PTR pContext // optional
);[DllImport("WINHTTP.dll", ExactSpelling = true)]
static extern uint WinHttpGetProxyForUrlEx2(
IntPtr hResolver, // void*
[MarshalAs(UnmanagedType.LPWStr)] string pcwszUrl, // LPCWSTR
IntPtr pAutoProxyOptions, // WINHTTP_AUTOPROXY_OPTIONS*
uint cbInterfaceSelectionContext, // DWORD
IntPtr pInterfaceSelectionContext, // BYTE* optional
UIntPtr pContext // UINT_PTR optional
);<DllImport("WINHTTP.dll", ExactSpelling:=True)>
Public Shared Function WinHttpGetProxyForUrlEx2(
hResolver As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> pcwszUrl As String, ' LPCWSTR
pAutoProxyOptions As IntPtr, ' WINHTTP_AUTOPROXY_OPTIONS*
cbInterfaceSelectionContext As UInteger, ' DWORD
pInterfaceSelectionContext As IntPtr, ' BYTE* optional
pContext As UIntPtr ' UINT_PTR optional
) As UInteger
End Function' hResolver : void*
' pcwszUrl : LPCWSTR
' pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS*
' cbInterfaceSelectionContext : DWORD
' pInterfaceSelectionContext : BYTE* optional
' pContext : UINT_PTR optional
Declare PtrSafe Function WinHttpGetProxyForUrlEx2 Lib "winhttp" ( _
ByVal hResolver As LongPtr, _
ByVal pcwszUrl As LongPtr, _
ByVal pAutoProxyOptions As LongPtr, _
ByVal cbInterfaceSelectionContext As Long, _
ByVal pInterfaceSelectionContext As LongPtr, _
ByVal pContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinHttpGetProxyForUrlEx2 = ctypes.windll.winhttp.WinHttpGetProxyForUrlEx2
WinHttpGetProxyForUrlEx2.restype = wintypes.DWORD
WinHttpGetProxyForUrlEx2.argtypes = [
ctypes.POINTER(None), # hResolver : void*
wintypes.LPCWSTR, # pcwszUrl : LPCWSTR
ctypes.c_void_p, # pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS*
wintypes.DWORD, # cbInterfaceSelectionContext : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pInterfaceSelectionContext : BYTE* optional
ctypes.c_size_t, # pContext : UINT_PTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpGetProxyForUrlEx2 = Fiddle::Function.new(
lib['WinHttpGetProxyForUrlEx2'],
[
Fiddle::TYPE_VOIDP, # hResolver : void*
Fiddle::TYPE_VOIDP, # pcwszUrl : LPCWSTR
Fiddle::TYPE_VOIDP, # pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS*
-Fiddle::TYPE_INT, # cbInterfaceSelectionContext : DWORD
Fiddle::TYPE_VOIDP, # pInterfaceSelectionContext : BYTE* optional
Fiddle::TYPE_UINTPTR_T, # pContext : UINT_PTR optional
],
-Fiddle::TYPE_INT)#[link(name = "winhttp")]
extern "system" {
fn WinHttpGetProxyForUrlEx2(
hResolver: *mut (), // void*
pcwszUrl: *const u16, // LPCWSTR
pAutoProxyOptions: *mut WINHTTP_AUTOPROXY_OPTIONS, // WINHTTP_AUTOPROXY_OPTIONS*
cbInterfaceSelectionContext: u32, // DWORD
pInterfaceSelectionContext: *mut u8, // BYTE* optional
pContext: usize // UINT_PTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINHTTP.dll")]
public static extern uint WinHttpGetProxyForUrlEx2(IntPtr hResolver, [MarshalAs(UnmanagedType.LPWStr)] string pcwszUrl, IntPtr pAutoProxyOptions, uint cbInterfaceSelectionContext, IntPtr pInterfaceSelectionContext, UIntPtr pContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpGetProxyForUrlEx2' -Namespace Win32 -PassThru
# $api::WinHttpGetProxyForUrlEx2(hResolver, pcwszUrl, pAutoProxyOptions, cbInterfaceSelectionContext, pInterfaceSelectionContext, pContext)#uselib "WINHTTP.dll"
#func global WinHttpGetProxyForUrlEx2 "WinHttpGetProxyForUrlEx2" sptr, sptr, sptr, sptr, sptr, sptr
; WinHttpGetProxyForUrlEx2 hResolver, pcwszUrl, varptr(pAutoProxyOptions), cbInterfaceSelectionContext, varptr(pInterfaceSelectionContext), pContext ; 戻り値は stat
; hResolver : void* -> "sptr"
; pcwszUrl : LPCWSTR -> "sptr"
; pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS* -> "sptr"
; cbInterfaceSelectionContext : DWORD -> "sptr"
; pInterfaceSelectionContext : BYTE* optional -> "sptr"
; pContext : UINT_PTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WINHTTP.dll" #cfunc global WinHttpGetProxyForUrlEx2 "WinHttpGetProxyForUrlEx2" sptr, wstr, var, int, var, sptr ; res = WinHttpGetProxyForUrlEx2(hResolver, pcwszUrl, pAutoProxyOptions, cbInterfaceSelectionContext, pInterfaceSelectionContext, pContext) ; hResolver : void* -> "sptr" ; pcwszUrl : LPCWSTR -> "wstr" ; pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS* -> "var" ; cbInterfaceSelectionContext : DWORD -> "int" ; pInterfaceSelectionContext : BYTE* optional -> "var" ; pContext : UINT_PTR optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WINHTTP.dll" #cfunc global WinHttpGetProxyForUrlEx2 "WinHttpGetProxyForUrlEx2" sptr, wstr, sptr, int, sptr, sptr ; res = WinHttpGetProxyForUrlEx2(hResolver, pcwszUrl, varptr(pAutoProxyOptions), cbInterfaceSelectionContext, varptr(pInterfaceSelectionContext), pContext) ; hResolver : void* -> "sptr" ; pcwszUrl : LPCWSTR -> "wstr" ; pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS* -> "sptr" ; cbInterfaceSelectionContext : DWORD -> "int" ; pInterfaceSelectionContext : BYTE* optional -> "sptr" ; pContext : UINT_PTR optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD WinHttpGetProxyForUrlEx2(void* hResolver, LPCWSTR pcwszUrl, WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions, DWORD cbInterfaceSelectionContext, BYTE* pInterfaceSelectionContext, UINT_PTR pContext) #uselib "WINHTTP.dll" #cfunc global WinHttpGetProxyForUrlEx2 "WinHttpGetProxyForUrlEx2" intptr, wstr, var, int, var, intptr ; res = WinHttpGetProxyForUrlEx2(hResolver, pcwszUrl, pAutoProxyOptions, cbInterfaceSelectionContext, pInterfaceSelectionContext, pContext) ; hResolver : void* -> "intptr" ; pcwszUrl : LPCWSTR -> "wstr" ; pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS* -> "var" ; cbInterfaceSelectionContext : DWORD -> "int" ; pInterfaceSelectionContext : BYTE* optional -> "var" ; pContext : UINT_PTR optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD WinHttpGetProxyForUrlEx2(void* hResolver, LPCWSTR pcwszUrl, WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions, DWORD cbInterfaceSelectionContext, BYTE* pInterfaceSelectionContext, UINT_PTR pContext) #uselib "WINHTTP.dll" #cfunc global WinHttpGetProxyForUrlEx2 "WinHttpGetProxyForUrlEx2" intptr, wstr, intptr, int, intptr, intptr ; res = WinHttpGetProxyForUrlEx2(hResolver, pcwszUrl, varptr(pAutoProxyOptions), cbInterfaceSelectionContext, varptr(pInterfaceSelectionContext), pContext) ; hResolver : void* -> "intptr" ; pcwszUrl : LPCWSTR -> "wstr" ; pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS* -> "intptr" ; cbInterfaceSelectionContext : DWORD -> "int" ; pInterfaceSelectionContext : BYTE* optional -> "intptr" ; pContext : UINT_PTR optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
procWinHttpGetProxyForUrlEx2 = winhttp.NewProc("WinHttpGetProxyForUrlEx2")
)
// hResolver (void*), pcwszUrl (LPCWSTR), pAutoProxyOptions (WINHTTP_AUTOPROXY_OPTIONS*), cbInterfaceSelectionContext (DWORD), pInterfaceSelectionContext (BYTE* optional), pContext (UINT_PTR optional)
r1, _, err := procWinHttpGetProxyForUrlEx2.Call(
uintptr(hResolver),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwszUrl))),
uintptr(pAutoProxyOptions),
uintptr(cbInterfaceSelectionContext),
uintptr(pInterfaceSelectionContext),
uintptr(pContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WinHttpGetProxyForUrlEx2(
hResolver: Pointer; // void*
pcwszUrl: PWideChar; // LPCWSTR
pAutoProxyOptions: Pointer; // WINHTTP_AUTOPROXY_OPTIONS*
cbInterfaceSelectionContext: DWORD; // DWORD
pInterfaceSelectionContext: Pointer; // BYTE* optional
pContext: NativeUInt // UINT_PTR optional
): DWORD; stdcall;
external 'WINHTTP.dll' name 'WinHttpGetProxyForUrlEx2';result := DllCall("WINHTTP\WinHttpGetProxyForUrlEx2"
, "Ptr", hResolver ; void*
, "WStr", pcwszUrl ; LPCWSTR
, "Ptr", pAutoProxyOptions ; WINHTTP_AUTOPROXY_OPTIONS*
, "UInt", cbInterfaceSelectionContext ; DWORD
, "Ptr", pInterfaceSelectionContext ; BYTE* optional
, "UPtr", pContext ; UINT_PTR optional
, "UInt") ; return: DWORD●WinHttpGetProxyForUrlEx2(hResolver, pcwszUrl, pAutoProxyOptions, cbInterfaceSelectionContext, pInterfaceSelectionContext, pContext) = DLL("WINHTTP.dll", "dword WinHttpGetProxyForUrlEx2(void*, char*, void*, dword, void*, int)")
# 呼び出し: WinHttpGetProxyForUrlEx2(hResolver, pcwszUrl, pAutoProxyOptions, cbInterfaceSelectionContext, pInterfaceSelectionContext, pContext)
# hResolver : void* -> "void*"
# pcwszUrl : LPCWSTR -> "char*"
# pAutoProxyOptions : WINHTTP_AUTOPROXY_OPTIONS* -> "void*"
# cbInterfaceSelectionContext : DWORD -> "dword"
# pInterfaceSelectionContext : BYTE* optional -> "void*"
# pContext : UINT_PTR optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。