ホーム › Networking.WinHttp › WinHttpWriteProxySettings
WinHttpWriteProxySettings
関数WinHTTPのプロキシ設定を書き込んで保存する。
シグネチャ
// WINHTTP.dll
#include <windows.h>
DWORD WinHttpWriteProxySettings(
void* hSession,
BOOL fForceUpdate,
WINHTTP_PROXY_SETTINGS* pWinHttpProxySettings
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hSession | void* | in |
| fForceUpdate | BOOL | in |
| pWinHttpProxySettings | WINHTTP_PROXY_SETTINGS* | in |
戻り値の型: DWORD
各言語での呼び出し定義
// WINHTTP.dll
#include <windows.h>
DWORD WinHttpWriteProxySettings(
void* hSession,
BOOL fForceUpdate,
WINHTTP_PROXY_SETTINGS* pWinHttpProxySettings
);[DllImport("WINHTTP.dll", ExactSpelling = true)]
static extern uint WinHttpWriteProxySettings(
IntPtr hSession, // void*
bool fForceUpdate, // BOOL
IntPtr pWinHttpProxySettings // WINHTTP_PROXY_SETTINGS*
);<DllImport("WINHTTP.dll", ExactSpelling:=True)>
Public Shared Function WinHttpWriteProxySettings(
hSession As IntPtr, ' void*
fForceUpdate As Boolean, ' BOOL
pWinHttpProxySettings As IntPtr ' WINHTTP_PROXY_SETTINGS*
) As UInteger
End Function' hSession : void*
' fForceUpdate : BOOL
' pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS*
Declare PtrSafe Function WinHttpWriteProxySettings Lib "winhttp" ( _
ByVal hSession As LongPtr, _
ByVal fForceUpdate As Long, _
ByVal pWinHttpProxySettings As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinHttpWriteProxySettings = ctypes.windll.winhttp.WinHttpWriteProxySettings
WinHttpWriteProxySettings.restype = wintypes.DWORD
WinHttpWriteProxySettings.argtypes = [
ctypes.POINTER(None), # hSession : void*
wintypes.BOOL, # fForceUpdate : BOOL
ctypes.c_void_p, # pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpWriteProxySettings = Fiddle::Function.new(
lib['WinHttpWriteProxySettings'],
[
Fiddle::TYPE_VOIDP, # hSession : void*
Fiddle::TYPE_INT, # fForceUpdate : BOOL
Fiddle::TYPE_VOIDP, # pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS*
],
-Fiddle::TYPE_INT)#[link(name = "winhttp")]
extern "system" {
fn WinHttpWriteProxySettings(
hSession: *mut (), // void*
fForceUpdate: i32, // BOOL
pWinHttpProxySettings: *mut WINHTTP_PROXY_SETTINGS // WINHTTP_PROXY_SETTINGS*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINHTTP.dll")]
public static extern uint WinHttpWriteProxySettings(IntPtr hSession, bool fForceUpdate, IntPtr pWinHttpProxySettings);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpWriteProxySettings' -Namespace Win32 -PassThru
# $api::WinHttpWriteProxySettings(hSession, fForceUpdate, pWinHttpProxySettings)#uselib "WINHTTP.dll"
#func global WinHttpWriteProxySettings "WinHttpWriteProxySettings" sptr, sptr, sptr
; WinHttpWriteProxySettings hSession, fForceUpdate, varptr(pWinHttpProxySettings) ; 戻り値は stat
; hSession : void* -> "sptr"
; fForceUpdate : BOOL -> "sptr"
; pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WINHTTP.dll" #cfunc global WinHttpWriteProxySettings "WinHttpWriteProxySettings" sptr, int, var ; res = WinHttpWriteProxySettings(hSession, fForceUpdate, pWinHttpProxySettings) ; hSession : void* -> "sptr" ; fForceUpdate : BOOL -> "int" ; pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WINHTTP.dll" #cfunc global WinHttpWriteProxySettings "WinHttpWriteProxySettings" sptr, int, sptr ; res = WinHttpWriteProxySettings(hSession, fForceUpdate, varptr(pWinHttpProxySettings)) ; hSession : void* -> "sptr" ; fForceUpdate : BOOL -> "int" ; pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD WinHttpWriteProxySettings(void* hSession, BOOL fForceUpdate, WINHTTP_PROXY_SETTINGS* pWinHttpProxySettings) #uselib "WINHTTP.dll" #cfunc global WinHttpWriteProxySettings "WinHttpWriteProxySettings" intptr, int, var ; res = WinHttpWriteProxySettings(hSession, fForceUpdate, pWinHttpProxySettings) ; hSession : void* -> "intptr" ; fForceUpdate : BOOL -> "int" ; pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD WinHttpWriteProxySettings(void* hSession, BOOL fForceUpdate, WINHTTP_PROXY_SETTINGS* pWinHttpProxySettings) #uselib "WINHTTP.dll" #cfunc global WinHttpWriteProxySettings "WinHttpWriteProxySettings" intptr, int, intptr ; res = WinHttpWriteProxySettings(hSession, fForceUpdate, varptr(pWinHttpProxySettings)) ; hSession : void* -> "intptr" ; fForceUpdate : BOOL -> "int" ; pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
procWinHttpWriteProxySettings = winhttp.NewProc("WinHttpWriteProxySettings")
)
// hSession (void*), fForceUpdate (BOOL), pWinHttpProxySettings (WINHTTP_PROXY_SETTINGS*)
r1, _, err := procWinHttpWriteProxySettings.Call(
uintptr(hSession),
uintptr(fForceUpdate),
uintptr(pWinHttpProxySettings),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WinHttpWriteProxySettings(
hSession: Pointer; // void*
fForceUpdate: BOOL; // BOOL
pWinHttpProxySettings: Pointer // WINHTTP_PROXY_SETTINGS*
): DWORD; stdcall;
external 'WINHTTP.dll' name 'WinHttpWriteProxySettings';result := DllCall("WINHTTP\WinHttpWriteProxySettings"
, "Ptr", hSession ; void*
, "Int", fForceUpdate ; BOOL
, "Ptr", pWinHttpProxySettings ; WINHTTP_PROXY_SETTINGS*
, "UInt") ; return: DWORD●WinHttpWriteProxySettings(hSession, fForceUpdate, pWinHttpProxySettings) = DLL("WINHTTP.dll", "dword WinHttpWriteProxySettings(void*, bool, void*)")
# 呼び出し: WinHttpWriteProxySettings(hSession, fForceUpdate, pWinHttpProxySettings)
# hSession : void* -> "void*"
# fForceUpdate : BOOL -> "bool"
# pWinHttpProxySettings : WINHTTP_PROXY_SETTINGS* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。