ホーム › Networking.WinInet › InternetSetOptionW
InternetSetOptionW
関数WinINetハンドルの指定したオプション値を設定する(Unicode)。
シグネチャ
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL InternetSetOptionW(
void* hInternet, // optional
DWORD dwOption,
void* lpBuffer, // optional
DWORD dwBufferLength
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hInternet | void* | inoptional | オプションを設定する対象のWinINetハンドル。NULLでグローバル設定。 |
| dwOption | DWORD | in | 設定するオプション種別を示すINTERNET_OPTION_*定数。 |
| lpBuffer | void* | inoptional | 設定する値を格納したバッファ(広域想定)へのポインタ。 |
| dwBufferLength | DWORD | in | lpBufferのバイト数(オプションにより文字数の場合あり)。 |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL InternetSetOptionW(
void* hInternet, // optional
DWORD dwOption,
void* lpBuffer, // optional
DWORD dwBufferLength
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool InternetSetOptionW(
IntPtr hInternet, // void* optional
uint dwOption, // DWORD
IntPtr lpBuffer, // void* optional
uint dwBufferLength // DWORD
);<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function InternetSetOptionW(
hInternet As IntPtr, ' void* optional
dwOption As UInteger, ' DWORD
lpBuffer As IntPtr, ' void* optional
dwBufferLength As UInteger ' DWORD
) As Boolean
End Function' hInternet : void* optional
' dwOption : DWORD
' lpBuffer : void* optional
' dwBufferLength : DWORD
Declare PtrSafe Function InternetSetOptionW Lib "wininet" ( _
ByVal hInternet As LongPtr, _
ByVal dwOption As Long, _
ByVal lpBuffer As LongPtr, _
ByVal dwBufferLength 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
InternetSetOptionW = ctypes.windll.wininet.InternetSetOptionW
InternetSetOptionW.restype = wintypes.BOOL
InternetSetOptionW.argtypes = [
ctypes.POINTER(None), # hInternet : void* optional
wintypes.DWORD, # dwOption : DWORD
ctypes.POINTER(None), # lpBuffer : void* optional
wintypes.DWORD, # dwBufferLength : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
InternetSetOptionW = Fiddle::Function.new(
lib['InternetSetOptionW'],
[
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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wininet")]
extern "system" {
fn InternetSetOptionW(
hInternet: *mut (), // void* optional
dwOption: u32, // DWORD
lpBuffer: *mut (), // void* optional
dwBufferLength: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool InternetSetOptionW(IntPtr hInternet, uint dwOption, IntPtr lpBuffer, uint dwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetSetOptionW' -Namespace Win32 -PassThru
# $api::InternetSetOptionW(hInternet, dwOption, lpBuffer, dwBufferLength)#uselib "WININET.dll"
#func global InternetSetOptionW "InternetSetOptionW" wptr, wptr, wptr, wptr
; InternetSetOptionW hInternet, dwOption, lpBuffer, dwBufferLength ; 戻り値は stat
; hInternet : void* optional -> "wptr"
; dwOption : DWORD -> "wptr"
; lpBuffer : void* optional -> "wptr"
; dwBufferLength : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WININET.dll"
#cfunc global InternetSetOptionW "InternetSetOptionW" sptr, int, sptr, int
; res = InternetSetOptionW(hInternet, dwOption, lpBuffer, dwBufferLength)
; hInternet : void* optional -> "sptr"
; dwOption : DWORD -> "int"
; lpBuffer : void* optional -> "sptr"
; dwBufferLength : DWORD -> "int"; BOOL InternetSetOptionW(void* hInternet, DWORD dwOption, void* lpBuffer, DWORD dwBufferLength)
#uselib "WININET.dll"
#cfunc global InternetSetOptionW "InternetSetOptionW" intptr, int, intptr, int
; res = InternetSetOptionW(hInternet, dwOption, lpBuffer, dwBufferLength)
; hInternet : void* optional -> "intptr"
; dwOption : DWORD -> "int"
; lpBuffer : void* optional -> "intptr"
; dwBufferLength : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procInternetSetOptionW = wininet.NewProc("InternetSetOptionW")
)
// hInternet (void* optional), dwOption (DWORD), lpBuffer (void* optional), dwBufferLength (DWORD)
r1, _, err := procInternetSetOptionW.Call(
uintptr(hInternet),
uintptr(dwOption),
uintptr(lpBuffer),
uintptr(dwBufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction InternetSetOptionW(
hInternet: Pointer; // void* optional
dwOption: DWORD; // DWORD
lpBuffer: Pointer; // void* optional
dwBufferLength: DWORD // DWORD
): BOOL; stdcall;
external 'WININET.dll' name 'InternetSetOptionW';result := DllCall("WININET\InternetSetOptionW"
, "Ptr", hInternet ; void* optional
, "UInt", dwOption ; DWORD
, "Ptr", lpBuffer ; void* optional
, "UInt", dwBufferLength ; DWORD
, "Int") ; return: BOOL●InternetSetOptionW(hInternet, dwOption, lpBuffer, dwBufferLength) = DLL("WININET.dll", "bool InternetSetOptionW(void*, dword, void*, dword)")
# 呼び出し: InternetSetOptionW(hInternet, dwOption, lpBuffer, dwBufferLength)
# hInternet : void* optional -> "void*"
# dwOption : DWORD -> "dword"
# lpBuffer : void* optional -> "void*"
# dwBufferLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。