ホーム › Networking.WinInet › InternetSetOptionA
InternetSetOptionA
関数WinINetハンドルの指定したオプション値を設定する(ANSI)。
シグネチャ
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL InternetSetOptionA(
void* hInternet, // optional
DWORD dwOption,
void* lpBuffer, // optional
DWORD dwBufferLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInternet | void* | inoptional |
| dwOption | DWORD | in |
| lpBuffer | void* | inoptional |
| dwBufferLength | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL InternetSetOptionA(
void* hInternet, // optional
DWORD dwOption,
void* lpBuffer, // optional
DWORD dwBufferLength
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool InternetSetOptionA(
IntPtr hInternet, // void* optional
uint dwOption, // DWORD
IntPtr lpBuffer, // void* optional
uint dwBufferLength // DWORD
);<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function InternetSetOptionA(
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 InternetSetOptionA Lib "wininet" ( _
ByVal hInternet As LongPtr, _
ByVal dwOption As Long, _
ByVal lpBuffer As LongPtr, _
ByVal dwBufferLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
InternetSetOptionA = ctypes.windll.wininet.InternetSetOptionA
InternetSetOptionA.restype = wintypes.BOOL
InternetSetOptionA.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')
InternetSetOptionA = Fiddle::Function.new(
lib['InternetSetOptionA'],
[
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)#[link(name = "wininet")]
extern "system" {
fn InternetSetOptionA(
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.Ansi, SetLastError = true)]
public static extern bool InternetSetOptionA(IntPtr hInternet, uint dwOption, IntPtr lpBuffer, uint dwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetSetOptionA' -Namespace Win32 -PassThru
# $api::InternetSetOptionA(hInternet, dwOption, lpBuffer, dwBufferLength)#uselib "WININET.dll"
#func global InternetSetOptionA "InternetSetOptionA" sptr, sptr, sptr, sptr
; InternetSetOptionA hInternet, dwOption, lpBuffer, dwBufferLength ; 戻り値は stat
; hInternet : void* optional -> "sptr"
; dwOption : DWORD -> "sptr"
; lpBuffer : void* optional -> "sptr"
; dwBufferLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WININET.dll"
#cfunc global InternetSetOptionA "InternetSetOptionA" sptr, int, sptr, int
; res = InternetSetOptionA(hInternet, dwOption, lpBuffer, dwBufferLength)
; hInternet : void* optional -> "sptr"
; dwOption : DWORD -> "int"
; lpBuffer : void* optional -> "sptr"
; dwBufferLength : DWORD -> "int"; BOOL InternetSetOptionA(void* hInternet, DWORD dwOption, void* lpBuffer, DWORD dwBufferLength)
#uselib "WININET.dll"
#cfunc global InternetSetOptionA "InternetSetOptionA" intptr, int, intptr, int
; res = InternetSetOptionA(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")
procInternetSetOptionA = wininet.NewProc("InternetSetOptionA")
)
// hInternet (void* optional), dwOption (DWORD), lpBuffer (void* optional), dwBufferLength (DWORD)
r1, _, err := procInternetSetOptionA.Call(
uintptr(hInternet),
uintptr(dwOption),
uintptr(lpBuffer),
uintptr(dwBufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction InternetSetOptionA(
hInternet: Pointer; // void* optional
dwOption: DWORD; // DWORD
lpBuffer: Pointer; // void* optional
dwBufferLength: DWORD // DWORD
): BOOL; stdcall;
external 'WININET.dll' name 'InternetSetOptionA';result := DllCall("WININET\InternetSetOptionA"
, "Ptr", hInternet ; void* optional
, "UInt", dwOption ; DWORD
, "Ptr", lpBuffer ; void* optional
, "UInt", dwBufferLength ; DWORD
, "Int") ; return: BOOL●InternetSetOptionA(hInternet, dwOption, lpBuffer, dwBufferLength) = DLL("WININET.dll", "bool InternetSetOptionA(void*, dword, void*, dword)")
# 呼び出し: InternetSetOptionA(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)。