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

WinHttpCreateProxyResolver

関数
非同期プロキシ解決用のリゾルバを作成する。
DLLWINHTTP.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD WinHttpCreateProxyResolver(
    void* hSession,
    void** phResolver
);

パラメーター

名前方向説明
hSessionvoid*in前回の WinHttpOpen の呼び出しによって返された有効な HINTERNET WinHTTP セッションハンドルです。このセッションハンドルは WINHTTP_FLAG_ASYNC を使用して開かれている必要があります。
phResolvervoid**outWinHttpGetProxyForUrlEx で使用する新しいハンドルへのポインターです。実行中の操作が完了またはキャンセルされたときは、このハンドルを WinHttpCloseHandle で閉じてください。

戻り値の型: DWORD

公式ドキュメント

WinHttpGetProxyForUrlEx で使用するためのハンドルを作成します。

戻り値

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

以下のコードが返される場合があります。 説明
ERROR_SUCCESS
操作が成功しました。
ERROR_INVALID_HANDLE
hSession が NULL です。
ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
hSessionWinHttpOpen の呼び出しの結果ではないか、または hSessionWINHTTP_FLAG_ASYNC を使用して非同期としてマークされていません。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

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

WinHttpCreateProxyResolver = ctypes.windll.winhttp.WinHttpCreateProxyResolver
WinHttpCreateProxyResolver.restype = wintypes.DWORD
WinHttpCreateProxyResolver.argtypes = [
    ctypes.POINTER(None),  # hSession : void*
    ctypes.c_void_p,  # phResolver : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpCreateProxyResolver = Fiddle::Function.new(
  lib['WinHttpCreateProxyResolver'],
  [
    Fiddle::TYPE_VOIDP,  # hSession : void*
    Fiddle::TYPE_VOIDP,  # phResolver : void** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "winhttp")]
extern "system" {
    fn WinHttpCreateProxyResolver(
        hSession: *mut (),  // void*
        phResolver: *mut *mut ()  // void** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WINHTTP.dll")]
public static extern uint WinHttpCreateProxyResolver(IntPtr hSession, IntPtr phResolver);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpCreateProxyResolver' -Namespace Win32 -PassThru
# $api::WinHttpCreateProxyResolver(hSession, phResolver)
#uselib "WINHTTP.dll"
#func global WinHttpCreateProxyResolver "WinHttpCreateProxyResolver" sptr, sptr
; WinHttpCreateProxyResolver hSession, phResolver   ; 戻り値は stat
; hSession : void* -> "sptr"
; phResolver : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WINHTTP.dll"
#cfunc global WinHttpCreateProxyResolver "WinHttpCreateProxyResolver" sptr, sptr
; res = WinHttpCreateProxyResolver(hSession, phResolver)
; hSession : void* -> "sptr"
; phResolver : void** out -> "sptr"
; DWORD WinHttpCreateProxyResolver(void* hSession, void** phResolver)
#uselib "WINHTTP.dll"
#cfunc global WinHttpCreateProxyResolver "WinHttpCreateProxyResolver" intptr, intptr
; res = WinHttpCreateProxyResolver(hSession, phResolver)
; hSession : void* -> "intptr"
; phResolver : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
	procWinHttpCreateProxyResolver = winhttp.NewProc("WinHttpCreateProxyResolver")
)

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

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

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

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

let winhttpcreateproxyresolver =
  foreign "WinHttpCreateProxyResolver"
    ((ptr void) @-> (ptr void) @-> returning uint32_t)
(* hSession : void* -> (ptr void) *)
(* phResolver : void** 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 ("WinHttpCreateProxyResolver" win-http-create-proxy-resolver :convention :stdcall) :uint32
  (h-session :pointer)   ; void*
  (ph-resolver :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinHttpCreateProxyResolver = Win32::API::More->new('WINHTTP',
    'DWORD WinHttpCreateProxyResolver(LPVOID hSession, LPVOID phResolver)');
# my $ret = $WinHttpCreateProxyResolver->Call($hSession, $phResolver);
# hSession : void* -> LPVOID
# phResolver : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。