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

WinHttpGetProxyResult

関数
非同期プロキシ解決の結果を取得する。
DLLWINHTTP.dll呼出規約winapi対応OSwindows8.0

シグネチャ

// WINHTTP.dll
#include <windows.h>

DWORD WinHttpGetProxyResult(
    void* hResolver,
    WINHTTP_PROXY_RESULT* pProxyResult
);

パラメーター

名前方向説明
hResolvervoid*in以前に完了した WinHttpGetProxyForUrlEx の呼び出しを発行するために使用したリゾルバー ハンドルです。
pProxyResultWINHTTP_PROXY_RESULT*out以前の WinHttpGetProxyForUrlEx の呼び出し結果を格納する WINHTTP_PROXY_RESULT 構造体へのポインターです。結果は WinHttpFreeProxyResult を呼び出して解放する必要があります。

戻り値の型: DWORD

公式ドキュメント

WinHttpGetProxyResult 関数は、WinHttpGetProxyForUrlEx の呼び出し結果を取得します。

戻り値

操作の結果を示すステータス コードです。

次のコードが返される場合があります。 説明
ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
指定されたハンドルの種類が、この操作に対して正しくありません。
ERROR_WINHTTP_INCORRECT_HANDLE_STATE
リゾルバー ハンドルが WinHttpGetProxyForUrlEx の呼び出しを正常に完了していません。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// WINHTTP.dll
#include <windows.h>

DWORD WinHttpGetProxyResult(
    void* hResolver,
    WINHTTP_PROXY_RESULT* pProxyResult
);
[DllImport("WINHTTP.dll", ExactSpelling = true)]
static extern uint WinHttpGetProxyResult(
    IntPtr hResolver,   // void*
    IntPtr pProxyResult   // WINHTTP_PROXY_RESULT* out
);
<DllImport("WINHTTP.dll", ExactSpelling:=True)>
Public Shared Function WinHttpGetProxyResult(
    hResolver As IntPtr,   ' void*
    pProxyResult As IntPtr   ' WINHTTP_PROXY_RESULT* out
) As UInteger
End Function
' hResolver : void*
' pProxyResult : WINHTTP_PROXY_RESULT* out
Declare PtrSafe Function WinHttpGetProxyResult Lib "winhttp" ( _
    ByVal hResolver As LongPtr, _
    ByVal pProxyResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinHttpGetProxyResult = ctypes.windll.winhttp.WinHttpGetProxyResult
WinHttpGetProxyResult.restype = wintypes.DWORD
WinHttpGetProxyResult.argtypes = [
    ctypes.POINTER(None),  # hResolver : void*
    ctypes.c_void_p,  # pProxyResult : WINHTTP_PROXY_RESULT* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpGetProxyResult = Fiddle::Function.new(
  lib['WinHttpGetProxyResult'],
  [
    Fiddle::TYPE_VOIDP,  # hResolver : void*
    Fiddle::TYPE_VOIDP,  # pProxyResult : WINHTTP_PROXY_RESULT* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "winhttp")]
extern "system" {
    fn WinHttpGetProxyResult(
        hResolver: *mut (),  // void*
        pProxyResult: *mut WINHTTP_PROXY_RESULT  // WINHTTP_PROXY_RESULT* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WINHTTP.dll")]
public static extern uint WinHttpGetProxyResult(IntPtr hResolver, IntPtr pProxyResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpGetProxyResult' -Namespace Win32 -PassThru
# $api::WinHttpGetProxyResult(hResolver, pProxyResult)
#uselib "WINHTTP.dll"
#func global WinHttpGetProxyResult "WinHttpGetProxyResult" sptr, sptr
; WinHttpGetProxyResult hResolver, varptr(pProxyResult)   ; 戻り値は stat
; hResolver : void* -> "sptr"
; pProxyResult : WINHTTP_PROXY_RESULT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WINHTTP.dll"
#cfunc global WinHttpGetProxyResult "WinHttpGetProxyResult" sptr, var
; res = WinHttpGetProxyResult(hResolver, pProxyResult)
; hResolver : void* -> "sptr"
; pProxyResult : WINHTTP_PROXY_RESULT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD WinHttpGetProxyResult(void* hResolver, WINHTTP_PROXY_RESULT* pProxyResult)
#uselib "WINHTTP.dll"
#cfunc global WinHttpGetProxyResult "WinHttpGetProxyResult" intptr, var
; res = WinHttpGetProxyResult(hResolver, pProxyResult)
; hResolver : void* -> "intptr"
; pProxyResult : WINHTTP_PROXY_RESULT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
	procWinHttpGetProxyResult = winhttp.NewProc("WinHttpGetProxyResult")
)

// hResolver (void*), pProxyResult (WINHTTP_PROXY_RESULT* out)
r1, _, err := procWinHttpGetProxyResult.Call(
	uintptr(hResolver),
	uintptr(pProxyResult),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WinHttpGetProxyResult(
  hResolver: Pointer;   // void*
  pProxyResult: Pointer   // WINHTTP_PROXY_RESULT* out
): DWORD; stdcall;
  external 'WINHTTP.dll' name 'WinHttpGetProxyResult';
result := DllCall("WINHTTP\WinHttpGetProxyResult"
    , "Ptr", hResolver   ; void*
    , "Ptr", pProxyResult   ; WINHTTP_PROXY_RESULT* out
    , "UInt")   ; return: DWORD
●WinHttpGetProxyResult(hResolver, pProxyResult) = DLL("WINHTTP.dll", "dword WinHttpGetProxyResult(void*, void*)")
# 呼び出し: WinHttpGetProxyResult(hResolver, pProxyResult)
# hResolver : void* -> "void*"
# pProxyResult : WINHTTP_PROXY_RESULT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "winhttp" fn WinHttpGetProxyResult(
    hResolver: ?*anyopaque, // void*
    pProxyResult: [*c]WINHTTP_PROXY_RESULT // WINHTTP_PROXY_RESULT* out
) callconv(std.os.windows.WINAPI) u32;
proc WinHttpGetProxyResult(
    hResolver: pointer,  # void*
    pProxyResult: ptr WINHTTP_PROXY_RESULT  # WINHTTP_PROXY_RESULT* out
): uint32 {.importc: "WinHttpGetProxyResult", stdcall, dynlib: "WINHTTP.dll".}
pragma(lib, "winhttp");
extern(Windows)
uint WinHttpGetProxyResult(
    void* hResolver,   // void*
    WINHTTP_PROXY_RESULT* pProxyResult   // WINHTTP_PROXY_RESULT* out
);
ccall((:WinHttpGetProxyResult, "WINHTTP.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Ptr{WINHTTP_PROXY_RESULT}),
      hResolver, pProxyResult)
# hResolver : void* -> Ptr{Cvoid}
# pProxyResult : WINHTTP_PROXY_RESULT* out -> Ptr{WINHTTP_PROXY_RESULT}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t WinHttpGetProxyResult(
    void* hResolver,
    void* pProxyResult);
]]
local winhttp = ffi.load("winhttp")
-- winhttp.WinHttpGetProxyResult(hResolver, pProxyResult)
-- hResolver : void*
-- pProxyResult : WINHTTP_PROXY_RESULT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WINHTTP.dll');
const WinHttpGetProxyResult = lib.func('__stdcall', 'WinHttpGetProxyResult', 'uint32_t', ['void *', 'void *']);
// WinHttpGetProxyResult(hResolver, pProxyResult)
// hResolver : void* -> 'void *'
// pProxyResult : WINHTTP_PROXY_RESULT* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WINHTTP.dll", {
  WinHttpGetProxyResult: { parameters: ["pointer", "pointer"], result: "u32" },
});
// lib.symbols.WinHttpGetProxyResult(hResolver, pProxyResult)
// hResolver : void* -> "pointer"
// pProxyResult : WINHTTP_PROXY_RESULT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t WinHttpGetProxyResult(
    void* hResolver,
    void* pProxyResult);
C, "WINHTTP.dll");
// $ffi->WinHttpGetProxyResult(hResolver, pProxyResult);
// hResolver : void*
// pProxyResult : WINHTTP_PROXY_RESULT* out
// 構造体/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 Winhttp extends StdCallLibrary {
    Winhttp INSTANCE = Native.load("winhttp", Winhttp.class);
    int WinHttpGetProxyResult(
        Pointer hResolver,   // void*
        Pointer pProxyResult   // WINHTTP_PROXY_RESULT* out
    );
}
@[Link("winhttp")]
lib LibWINHTTP
  fun WinHttpGetProxyResult = WinHttpGetProxyResult(
    hResolver : Void*,   # void*
    pProxyResult : WINHTTP_PROXY_RESULT*   # WINHTTP_PROXY_RESULT* out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WinHttpGetProxyResultNative = Uint32 Function(Pointer<Void>, Pointer<Void>);
typedef WinHttpGetProxyResultDart = int Function(Pointer<Void>, Pointer<Void>);
final WinHttpGetProxyResult = DynamicLibrary.open('WINHTTP.dll')
    .lookupFunction<WinHttpGetProxyResultNative, WinHttpGetProxyResultDart>('WinHttpGetProxyResult');
// hResolver : void* -> Pointer<Void>
// pProxyResult : WINHTTP_PROXY_RESULT* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinHttpGetProxyResult(
  hResolver: Pointer;   // void*
  pProxyResult: Pointer   // WINHTTP_PROXY_RESULT* out
): DWORD; stdcall;
  external 'WINHTTP.dll' name 'WinHttpGetProxyResult';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinHttpGetProxyResult"
  c_WinHttpGetProxyResult :: Ptr () -> Ptr () -> IO Word32
-- hResolver : void* -> Ptr ()
-- pProxyResult : WINHTTP_PROXY_RESULT* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winhttpgetproxyresult =
  foreign "WinHttpGetProxyResult"
    ((ptr void) @-> (ptr void) @-> returning uint32_t)
(* hResolver : void* -> (ptr void) *)
(* pProxyResult : WINHTTP_PROXY_RESULT* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winhttp (t "WINHTTP.dll"))
(cffi:use-foreign-library winhttp)

(cffi:defcfun ("WinHttpGetProxyResult" win-http-get-proxy-result :convention :stdcall) :uint32
  (h-resolver :pointer)   ; void*
  (p-proxy-result :pointer))   ; WINHTTP_PROXY_RESULT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinHttpGetProxyResult = Win32::API::More->new('WINHTTP',
    'DWORD WinHttpGetProxyResult(LPVOID hResolver, LPVOID pProxyResult)');
# my $ret = $WinHttpGetProxyResult->Call($hResolver, $pProxyResult);
# hResolver : void* -> LPVOID
# pProxyResult : WINHTTP_PROXY_RESULT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型