ホーム › Networking.WinInet › InternetSetOptionExA
InternetSetOptionExA
関数WinINetハンドルのオプション値を拡張フラグ付きで設定する(ANSI)。
シグネチャ
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL InternetSetOptionExA(
void* hInternet, // optional
DWORD dwOption,
void* lpBuffer, // optional
DWORD dwBufferLength,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hInternet | void* | inoptional | 使用されません。 |
| dwOption | DWORD | in | 使用されません。 |
| lpBuffer | void* | inoptional | 使用されません。 |
| dwBufferLength | DWORD | in | 使用されません。 |
| dwFlags | DWORD | in | 使用されません。 |
戻り値の型: BOOL
公式ドキュメント
サポートされていません。InternetSetOption 関数を呼び出すだけのスタブとして実装されており、InternetSetOptionEx 自体には機能がありません。現時点ではこの関数を使用しないでください。(ANSI)
戻り値
この関数は値を返しません。
解説(Remarks)
注意 WinINet はサーバー実装をサポートしていません。また、サービスから使用しないでください。サーバー実装やサービスでは Microsoft Windows HTTP Services (WinHTTP) を使用してください。
メモ
wininet.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして InternetSetOptionEx を定義します。エンコーディング非依存のエイリアスを、エンコーディング非依存でないコードと混在させて使用すると、不一致が生じてコンパイルエラーや実行時エラーの原因となることがあります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WININET.dll (ANSI / -A)
#include <windows.h>
BOOL InternetSetOptionExA(
void* hInternet, // optional
DWORD dwOption,
void* lpBuffer, // optional
DWORD dwBufferLength,
DWORD dwFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool InternetSetOptionExA(
IntPtr hInternet, // void* optional
uint dwOption, // DWORD
IntPtr lpBuffer, // void* optional
uint dwBufferLength, // DWORD
uint dwFlags // DWORD
);<DllImport("WININET.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function InternetSetOptionExA(
hInternet As IntPtr, ' void* optional
dwOption As UInteger, ' DWORD
lpBuffer As IntPtr, ' void* optional
dwBufferLength As UInteger, ' DWORD
dwFlags As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hInternet : void* optional
' dwOption : DWORD
' lpBuffer : void* optional
' dwBufferLength : DWORD
' dwFlags : DWORD
Declare PtrSafe Function InternetSetOptionExA Lib "wininet" ( _
ByVal hInternet As LongPtr, _
ByVal dwOption As Long, _
ByVal lpBuffer As LongPtr, _
ByVal dwBufferLength As Long, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
InternetSetOptionExA = ctypes.windll.wininet.InternetSetOptionExA
InternetSetOptionExA.restype = wintypes.BOOL
InternetSetOptionExA.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')
InternetSetOptionExA = Fiddle::Function.new(
lib['InternetSetOptionExA'],
[
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)#[link(name = "wininet")]
extern "system" {
fn InternetSetOptionExA(
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.Ansi)]
public static extern bool InternetSetOptionExA(IntPtr hInternet, uint dwOption, IntPtr lpBuffer, uint dwBufferLength, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetSetOptionExA' -Namespace Win32 -PassThru
# $api::InternetSetOptionExA(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)#uselib "WININET.dll"
#func global InternetSetOptionExA "InternetSetOptionExA" sptr, sptr, sptr, sptr, sptr
; InternetSetOptionExA hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags ; 戻り値は stat
; hInternet : void* optional -> "sptr"
; dwOption : DWORD -> "sptr"
; lpBuffer : void* optional -> "sptr"
; dwBufferLength : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WININET.dll"
#cfunc global InternetSetOptionExA "InternetSetOptionExA" sptr, int, sptr, int, int
; res = InternetSetOptionExA(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
; hInternet : void* optional -> "sptr"
; dwOption : DWORD -> "int"
; lpBuffer : void* optional -> "sptr"
; dwBufferLength : DWORD -> "int"
; dwFlags : DWORD -> "int"; BOOL InternetSetOptionExA(void* hInternet, DWORD dwOption, void* lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
#uselib "WININET.dll"
#cfunc global InternetSetOptionExA "InternetSetOptionExA" intptr, int, intptr, int, int
; res = InternetSetOptionExA(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")
procInternetSetOptionExA = wininet.NewProc("InternetSetOptionExA")
)
// hInternet (void* optional), dwOption (DWORD), lpBuffer (void* optional), dwBufferLength (DWORD), dwFlags (DWORD)
r1, _, err := procInternetSetOptionExA.Call(
uintptr(hInternet),
uintptr(dwOption),
uintptr(lpBuffer),
uintptr(dwBufferLength),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction InternetSetOptionExA(
hInternet: Pointer; // void* optional
dwOption: DWORD; // DWORD
lpBuffer: Pointer; // void* optional
dwBufferLength: DWORD; // DWORD
dwFlags: DWORD // DWORD
): BOOL; stdcall;
external 'WININET.dll' name 'InternetSetOptionExA';result := DllCall("WININET\InternetSetOptionExA"
, "Ptr", hInternet ; void* optional
, "UInt", dwOption ; DWORD
, "Ptr", lpBuffer ; void* optional
, "UInt", dwBufferLength ; DWORD
, "UInt", dwFlags ; DWORD
, "Int") ; return: BOOL●InternetSetOptionExA(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags) = DLL("WININET.dll", "bool InternetSetOptionExA(void*, dword, void*, dword, dword)")
# 呼び出し: InternetSetOptionExA(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)。const std = @import("std");
extern "wininet" fn InternetSetOptionExA(
hInternet: ?*anyopaque, // void* optional
dwOption: u32, // DWORD
lpBuffer: ?*anyopaque, // void* optional
dwBufferLength: u32, // DWORD
dwFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc InternetSetOptionExA(
hInternet: pointer, # void* optional
dwOption: uint32, # DWORD
lpBuffer: pointer, # void* optional
dwBufferLength: uint32, # DWORD
dwFlags: uint32 # DWORD
): int32 {.importc: "InternetSetOptionExA", stdcall, dynlib: "WININET.dll".}pragma(lib, "wininet");
extern(Windows)
int InternetSetOptionExA(
void* hInternet, // void* optional
uint dwOption, // DWORD
void* lpBuffer, // void* optional
uint dwBufferLength, // DWORD
uint dwFlags // DWORD
);ccall((:InternetSetOptionExA, "WININET.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Ptr{Cvoid}, UInt32, UInt32),
hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
# hInternet : void* optional -> Ptr{Cvoid}
# dwOption : DWORD -> UInt32
# lpBuffer : void* optional -> Ptr{Cvoid}
# dwBufferLength : DWORD -> UInt32
# dwFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t InternetSetOptionExA(
void* hInternet,
uint32_t dwOption,
void* lpBuffer,
uint32_t dwBufferLength,
uint32_t dwFlags);
]]
local wininet = ffi.load("wininet")
-- wininet.InternetSetOptionExA(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
-- hInternet : void* optional
-- dwOption : DWORD
-- lpBuffer : void* optional
-- dwBufferLength : DWORD
-- dwFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const InternetSetOptionExA = lib.func('__stdcall', 'InternetSetOptionExA', 'int32_t', ['void *', 'uint32_t', 'void *', 'uint32_t', 'uint32_t']);
// InternetSetOptionExA(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
// hInternet : void* optional -> 'void *'
// dwOption : DWORD -> 'uint32_t'
// lpBuffer : void* optional -> 'void *'
// dwBufferLength : DWORD -> 'uint32_t'
// dwFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
InternetSetOptionExA: { parameters: ["pointer", "u32", "pointer", "u32", "u32"], result: "i32" },
});
// lib.symbols.InternetSetOptionExA(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags)
// hInternet : void* optional -> "pointer"
// dwOption : DWORD -> "u32"
// lpBuffer : void* optional -> "pointer"
// dwBufferLength : DWORD -> "u32"
// dwFlags : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t InternetSetOptionExA(
void* hInternet,
uint32_t dwOption,
void* lpBuffer,
uint32_t dwBufferLength,
uint32_t dwFlags);
C, "WININET.dll");
// $ffi->InternetSetOptionExA(hInternet, dwOption, lpBuffer, dwBufferLength, dwFlags);
// hInternet : void* optional
// dwOption : DWORD
// lpBuffer : void* optional
// dwBufferLength : DWORD
// dwFlags : DWORD
// 構造体/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 Wininet extends StdCallLibrary {
Wininet INSTANCE = Native.load("wininet", Wininet.class, W32APIOptions.ASCII_OPTIONS);
boolean InternetSetOptionExA(
Pointer hInternet, // void* optional
int dwOption, // DWORD
Pointer lpBuffer, // void* optional
int dwBufferLength, // DWORD
int dwFlags // DWORD
);
}@[Link("wininet")]
lib LibWININET
fun InternetSetOptionExA = InternetSetOptionExA(
hInternet : Void*, # void* optional
dwOption : UInt32, # DWORD
lpBuffer : Void*, # void* optional
dwBufferLength : UInt32, # DWORD
dwFlags : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef InternetSetOptionExANative = Int32 Function(Pointer<Void>, Uint32, Pointer<Void>, Uint32, Uint32);
typedef InternetSetOptionExADart = int Function(Pointer<Void>, int, Pointer<Void>, int, int);
final InternetSetOptionExA = DynamicLibrary.open('WININET.dll')
.lookupFunction<InternetSetOptionExANative, InternetSetOptionExADart>('InternetSetOptionExA');
// hInternet : void* optional -> Pointer<Void>
// dwOption : DWORD -> Uint32
// lpBuffer : void* optional -> Pointer<Void>
// dwBufferLength : DWORD -> Uint32
// dwFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function InternetSetOptionExA(
hInternet: Pointer; // void* optional
dwOption: DWORD; // DWORD
lpBuffer: Pointer; // void* optional
dwBufferLength: DWORD; // DWORD
dwFlags: DWORD // DWORD
): BOOL; stdcall;
external 'WININET.dll' name 'InternetSetOptionExA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "InternetSetOptionExA"
c_InternetSetOptionExA :: Ptr () -> Word32 -> Ptr () -> Word32 -> Word32 -> IO CInt
-- hInternet : void* optional -> Ptr ()
-- dwOption : DWORD -> Word32
-- lpBuffer : void* optional -> Ptr ()
-- dwBufferLength : DWORD -> Word32
-- dwFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let internetsetoptionexa =
foreign "InternetSetOptionExA"
((ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> uint32_t @-> returning int32_t)
(* hInternet : void* optional -> (ptr void) *)
(* dwOption : DWORD -> uint32_t *)
(* lpBuffer : void* optional -> (ptr void) *)
(* dwBufferLength : DWORD -> uint32_t *)
(* dwFlags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("InternetSetOptionExA" internet-set-option-ex-a :convention :stdcall) :int32
(h-internet :pointer) ; void* optional
(dw-option :uint32) ; DWORD
(lp-buffer :pointer) ; void* optional
(dw-buffer-length :uint32) ; DWORD
(dw-flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $InternetSetOptionExA = Win32::API::More->new('WININET',
'BOOL InternetSetOptionExA(LPVOID hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)');
# my $ret = $InternetSetOptionExA->Call($hInternet, $dwOption, $lpBuffer, $dwBufferLength, $dwFlags);
# hInternet : void* optional -> LPVOID
# dwOption : DWORD -> DWORD
# lpBuffer : void* optional -> LPVOID
# dwBufferLength : DWORD -> DWORD
# dwFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f InternetSetOptionExW (Unicode版) — WinINetハンドルのオプション値を拡張フラグ付きで設定する(Unicode)。
類似 API
- f InternetSetOptionA — WinINetハンドルの指定したオプション値を設定する(ANSI)。