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

InternetSetOptionExW

関数
WinINetハンドルのオプション値を拡張フラグ付きで設定する(Unicode)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL InternetSetOptionExW(
    void* hInternet,   // optional
    DWORD dwOption,
    void* lpBuffer,   // optional
    DWORD dwBufferLength,
    DWORD dwFlags
);

パラメーター

名前方向
hInternetvoid*inoptional
dwOptionDWORDin
lpBuffervoid*inoptional
dwBufferLengthDWORDin
dwFlagsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL InternetSetOptionExW(
    void* hInternet,   // optional
    DWORD dwOption,
    void* lpBuffer,   // optional
    DWORD dwBufferLength,
    DWORD dwFlags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool InternetSetOptionExW(
    IntPtr hInternet,   // void* optional
    uint dwOption,   // DWORD
    IntPtr lpBuffer,   // void* optional
    uint dwBufferLength,   // DWORD
    uint dwFlags   // DWORD
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function InternetSetOptionExW(
    hInternet As IntPtr,   ' void* optional
    dwOption As UInteger,   ' DWORD
    lpBuffer As IntPtr,   ' void* optional
    dwBufferLength As UInteger,   ' DWORD
    dwFlags As UInteger   ' DWORD
) As Boolean
End Function
' hInternet : void* optional
' dwOption : DWORD
' lpBuffer : void* optional
' dwBufferLength : DWORD
' dwFlags : DWORD
Declare PtrSafe Function InternetSetOptionExW Lib "wininet" ( _
    ByVal hInternet As LongPtr, _
    ByVal dwOption As Long, _
    ByVal lpBuffer As LongPtr, _
    ByVal dwBufferLength As Long, _
    ByVal dwFlags As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

InternetSetOptionExW = ctypes.windll.wininet.InternetSetOptionExW
InternetSetOptionExW.restype = wintypes.BOOL
InternetSetOptionExW.argtypes = [
    ctypes.POINTER(None),  # hInternet : void* optional
    wintypes.DWORD,  # dwOption : DWORD
    ctypes.POINTER(None),  # lpBuffer : void* optional
    wintypes.DWORD,  # dwBufferLength : DWORD
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
InternetSetOptionExW = Fiddle::Function.new(
  lib['InternetSetOptionExW'],
  [
    Fiddle::TYPE_VOIDP,  # hInternet : void* optional
    -Fiddle::TYPE_INT,  # dwOption : DWORD
    Fiddle::TYPE_VOIDP,  # lpBuffer : void* optional
    -Fiddle::TYPE_INT,  # dwBufferLength : DWORD
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn InternetSetOptionExW(
        hInternet: *mut (),  // void* optional
        dwOption: u32,  // DWORD
        lpBuffer: *mut (),  // void* optional
        dwBufferLength: u32,  // DWORD
        dwFlags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode)]
public static extern bool InternetSetOptionExW(IntPtr hInternet, uint dwOption, IntPtr lpBuffer, uint dwBufferLength, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetSetOptionExW' -Namespace Win32 -PassThru
# $api::InternetSetOptionExW(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
#uselib "WININET.dll"
#func global InternetSetOptionExW "InternetSetOptionExW" wptr, wptr, wptr, wptr, wptr
; InternetSetOptionExW hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags   ; 戻り値は stat
; hInternet : void* optional -> "wptr"
; dwOption : DWORD -> "wptr"
; lpBuffer : void* optional -> "wptr"
; dwBufferLength : DWORD -> "wptr"
; dwFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WININET.dll"
#cfunc global InternetSetOptionExW "InternetSetOptionExW" sptr, int, sptr, int, int
; res = InternetSetOptionExW(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
; hInternet : void* optional -> "sptr"
; dwOption : DWORD -> "int"
; lpBuffer : void* optional -> "sptr"
; dwBufferLength : DWORD -> "int"
; dwFlags : DWORD -> "int"
; BOOL InternetSetOptionExW(void* hInternet, DWORD dwOption, void* lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
#uselib "WININET.dll"
#cfunc global InternetSetOptionExW "InternetSetOptionExW" intptr, int, intptr, int, int
; res = InternetSetOptionExW(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
; hInternet : void* optional -> "intptr"
; dwOption : DWORD -> "int"
; lpBuffer : void* optional -> "intptr"
; dwBufferLength : DWORD -> "int"
; dwFlags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procInternetSetOptionExW = wininet.NewProc("InternetSetOptionExW")
)

// hInternet (void* optional), dwOption (DWORD), lpBuffer (void* optional), dwBufferLength (DWORD), dwFlags (DWORD)
r1, _, err := procInternetSetOptionExW.Call(
	uintptr(hInternet),
	uintptr(dwOption),
	uintptr(lpBuffer),
	uintptr(dwBufferLength),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function InternetSetOptionExW(
  hInternet: Pointer;   // void* optional
  dwOption: DWORD;   // DWORD
  lpBuffer: Pointer;   // void* optional
  dwBufferLength: DWORD;   // DWORD
  dwFlags: DWORD   // DWORD
): BOOL; stdcall;
  external 'WININET.dll' name 'InternetSetOptionExW';
result := DllCall("WININET\InternetSetOptionExW"
    , "Ptr", hInternet   ; void* optional
    , "UInt", dwOption   ; DWORD
    , "Ptr", lpBuffer   ; void* optional
    , "UInt", dwBufferLength   ; DWORD
    , "UInt", dwFlags   ; DWORD
    , "Int")   ; return: BOOL
●InternetSetOptionExW(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags) = DLL("WININET.dll", "bool InternetSetOptionExW(void*, dword, void*, dword, dword)")
# 呼び出し: InternetSetOptionExW(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
# hInternet : void* optional -> "void*"
# dwOption : DWORD -> "dword"
# lpBuffer : void* optional -> "void*"
# dwBufferLength : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。