ホーム › System.Com.Urlmon › UrlMkSetSessionOption
UrlMkSetSessionOption
関数URLモニカーセッションのオプションを設定する。
シグネチャ
// urlmon.dll
#include <windows.h>
HRESULT UrlMkSetSessionOption(
DWORD dwOption,
void* pBuffer, // optional
DWORD dwBufferLength,
DWORD dwReserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwOption | DWORD | in | 設定するセッションオプションの識別子。URLMON_OPTION_*を指定する。 |
| pBuffer | void* | inoptional | 設定値が格納されたバッファへのポインタ。 |
| dwBufferLength | DWORD | in | pBufferの有効データのバイト数。 |
| dwReserved | DWORD | optional | 予約パラメータ。0を指定する必要がある。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// urlmon.dll
#include <windows.h>
HRESULT UrlMkSetSessionOption(
DWORD dwOption,
void* pBuffer, // optional
DWORD dwBufferLength,
DWORD dwReserved // optional
);[DllImport("urlmon.dll", ExactSpelling = true)]
static extern int UrlMkSetSessionOption(
uint dwOption, // DWORD
IntPtr pBuffer, // void* optional
uint dwBufferLength, // DWORD
uint dwReserved // DWORD optional
);<DllImport("urlmon.dll", ExactSpelling:=True)>
Public Shared Function UrlMkSetSessionOption(
dwOption As UInteger, ' DWORD
pBuffer As IntPtr, ' void* optional
dwBufferLength As UInteger, ' DWORD
dwReserved As UInteger ' DWORD optional
) As Integer
End Function' dwOption : DWORD
' pBuffer : void* optional
' dwBufferLength : DWORD
' dwReserved : DWORD optional
Declare PtrSafe Function UrlMkSetSessionOption Lib "urlmon" ( _
ByVal dwOption As Long, _
ByVal pBuffer As LongPtr, _
ByVal dwBufferLength As Long, _
ByVal dwReserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UrlMkSetSessionOption = ctypes.windll.urlmon.UrlMkSetSessionOption
UrlMkSetSessionOption.restype = ctypes.c_int
UrlMkSetSessionOption.argtypes = [
wintypes.DWORD, # dwOption : DWORD
ctypes.POINTER(None), # pBuffer : void* optional
wintypes.DWORD, # dwBufferLength : DWORD
wintypes.DWORD, # dwReserved : DWORD optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('urlmon.dll')
UrlMkSetSessionOption = Fiddle::Function.new(
lib['UrlMkSetSessionOption'],
[
-Fiddle::TYPE_INT, # dwOption : DWORD
Fiddle::TYPE_VOIDP, # pBuffer : void* optional
-Fiddle::TYPE_INT, # dwBufferLength : DWORD
-Fiddle::TYPE_INT, # dwReserved : DWORD optional
],
Fiddle::TYPE_INT)#[link(name = "urlmon")]
extern "system" {
fn UrlMkSetSessionOption(
dwOption: u32, // DWORD
pBuffer: *mut (), // void* optional
dwBufferLength: u32, // DWORD
dwReserved: u32 // DWORD optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("urlmon.dll")]
public static extern int UrlMkSetSessionOption(uint dwOption, IntPtr pBuffer, uint dwBufferLength, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'urlmon_UrlMkSetSessionOption' -Namespace Win32 -PassThru
# $api::UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved)#uselib "urlmon.dll"
#func global UrlMkSetSessionOption "UrlMkSetSessionOption" sptr, sptr, sptr, sptr
; UrlMkSetSessionOption dwOption, pBuffer, dwBufferLength, dwReserved ; 戻り値は stat
; dwOption : DWORD -> "sptr"
; pBuffer : void* optional -> "sptr"
; dwBufferLength : DWORD -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "urlmon.dll"
#cfunc global UrlMkSetSessionOption "UrlMkSetSessionOption" int, sptr, int, int
; res = UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved)
; dwOption : DWORD -> "int"
; pBuffer : void* optional -> "sptr"
; dwBufferLength : DWORD -> "int"
; dwReserved : DWORD optional -> "int"; HRESULT UrlMkSetSessionOption(DWORD dwOption, void* pBuffer, DWORD dwBufferLength, DWORD dwReserved)
#uselib "urlmon.dll"
#cfunc global UrlMkSetSessionOption "UrlMkSetSessionOption" int, intptr, int, int
; res = UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved)
; dwOption : DWORD -> "int"
; pBuffer : void* optional -> "intptr"
; dwBufferLength : DWORD -> "int"
; dwReserved : DWORD optional -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
urlmon = windows.NewLazySystemDLL("urlmon.dll")
procUrlMkSetSessionOption = urlmon.NewProc("UrlMkSetSessionOption")
)
// dwOption (DWORD), pBuffer (void* optional), dwBufferLength (DWORD), dwReserved (DWORD optional)
r1, _, err := procUrlMkSetSessionOption.Call(
uintptr(dwOption),
uintptr(pBuffer),
uintptr(dwBufferLength),
uintptr(dwReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction UrlMkSetSessionOption(
dwOption: DWORD; // DWORD
pBuffer: Pointer; // void* optional
dwBufferLength: DWORD; // DWORD
dwReserved: DWORD // DWORD optional
): Integer; stdcall;
external 'urlmon.dll' name 'UrlMkSetSessionOption';result := DllCall("urlmon\UrlMkSetSessionOption"
, "UInt", dwOption ; DWORD
, "Ptr", pBuffer ; void* optional
, "UInt", dwBufferLength ; DWORD
, "UInt", dwReserved ; DWORD optional
, "Int") ; return: HRESULT●UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved) = DLL("urlmon.dll", "int UrlMkSetSessionOption(dword, void*, dword, dword)")
# 呼び出し: UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved)
# dwOption : DWORD -> "dword"
# pBuffer : void* optional -> "void*"
# dwBufferLength : DWORD -> "dword"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "urlmon" fn UrlMkSetSessionOption(
dwOption: u32, // DWORD
pBuffer: ?*anyopaque, // void* optional
dwBufferLength: u32, // DWORD
dwReserved: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) i32;proc UrlMkSetSessionOption(
dwOption: uint32, # DWORD
pBuffer: pointer, # void* optional
dwBufferLength: uint32, # DWORD
dwReserved: uint32 # DWORD optional
): int32 {.importc: "UrlMkSetSessionOption", stdcall, dynlib: "urlmon.dll".}pragma(lib, "urlmon");
extern(Windows)
int UrlMkSetSessionOption(
uint dwOption, // DWORD
void* pBuffer, // void* optional
uint dwBufferLength, // DWORD
uint dwReserved // DWORD optional
);ccall((:UrlMkSetSessionOption, "urlmon.dll"), stdcall, Int32,
(UInt32, Ptr{Cvoid}, UInt32, UInt32),
dwOption, pBuffer, dwBufferLength, dwReserved)
# dwOption : DWORD -> UInt32
# pBuffer : void* optional -> Ptr{Cvoid}
# dwBufferLength : DWORD -> UInt32
# dwReserved : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t UrlMkSetSessionOption(
uint32_t dwOption,
void* pBuffer,
uint32_t dwBufferLength,
uint32_t dwReserved);
]]
local urlmon = ffi.load("urlmon")
-- urlmon.UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved)
-- dwOption : DWORD
-- pBuffer : void* optional
-- dwBufferLength : DWORD
-- dwReserved : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('urlmon.dll');
const UrlMkSetSessionOption = lib.func('__stdcall', 'UrlMkSetSessionOption', 'int32_t', ['uint32_t', 'void *', 'uint32_t', 'uint32_t']);
// UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved)
// dwOption : DWORD -> 'uint32_t'
// pBuffer : void* optional -> 'void *'
// dwBufferLength : DWORD -> 'uint32_t'
// dwReserved : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("urlmon.dll", {
UrlMkSetSessionOption: { parameters: ["u32", "pointer", "u32", "u32"], result: "i32" },
});
// lib.symbols.UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved)
// dwOption : DWORD -> "u32"
// pBuffer : void* optional -> "pointer"
// dwBufferLength : DWORD -> "u32"
// dwReserved : DWORD optional -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t UrlMkSetSessionOption(
uint32_t dwOption,
void* pBuffer,
uint32_t dwBufferLength,
uint32_t dwReserved);
C, "urlmon.dll");
// $ffi->UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved);
// dwOption : DWORD
// pBuffer : void* optional
// dwBufferLength : DWORD
// dwReserved : DWORD optional
// 構造体/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 Urlmon extends StdCallLibrary {
Urlmon INSTANCE = Native.load("urlmon", Urlmon.class);
int UrlMkSetSessionOption(
int dwOption, // DWORD
Pointer pBuffer, // void* optional
int dwBufferLength, // DWORD
int dwReserved // DWORD optional
);
}@[Link("urlmon")]
lib Liburlmon
fun UrlMkSetSessionOption = UrlMkSetSessionOption(
dwOption : UInt32, # DWORD
pBuffer : Void*, # void* optional
dwBufferLength : UInt32, # DWORD
dwReserved : UInt32 # DWORD optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UrlMkSetSessionOptionNative = Int32 Function(Uint32, Pointer<Void>, Uint32, Uint32);
typedef UrlMkSetSessionOptionDart = int Function(int, Pointer<Void>, int, int);
final UrlMkSetSessionOption = DynamicLibrary.open('urlmon.dll')
.lookupFunction<UrlMkSetSessionOptionNative, UrlMkSetSessionOptionDart>('UrlMkSetSessionOption');
// dwOption : DWORD -> Uint32
// pBuffer : void* optional -> Pointer<Void>
// dwBufferLength : DWORD -> Uint32
// dwReserved : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UrlMkSetSessionOption(
dwOption: DWORD; // DWORD
pBuffer: Pointer; // void* optional
dwBufferLength: DWORD; // DWORD
dwReserved: DWORD // DWORD optional
): Integer; stdcall;
external 'urlmon.dll' name 'UrlMkSetSessionOption';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UrlMkSetSessionOption"
c_UrlMkSetSessionOption :: Word32 -> Ptr () -> Word32 -> Word32 -> IO Int32
-- dwOption : DWORD -> Word32
-- pBuffer : void* optional -> Ptr ()
-- dwBufferLength : DWORD -> Word32
-- dwReserved : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let urlmksetsessionoption =
foreign "UrlMkSetSessionOption"
(uint32_t @-> (ptr void) @-> uint32_t @-> uint32_t @-> returning int32_t)
(* dwOption : DWORD -> uint32_t *)
(* pBuffer : void* optional -> (ptr void) *)
(* dwBufferLength : DWORD -> uint32_t *)
(* dwReserved : DWORD optional -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library urlmon (t "urlmon.dll"))
(cffi:use-foreign-library urlmon)
(cffi:defcfun ("UrlMkSetSessionOption" url-mk-set-session-option :convention :stdcall) :int32
(dw-option :uint32) ; DWORD
(p-buffer :pointer) ; void* optional
(dw-buffer-length :uint32) ; DWORD
(dw-reserved :uint32)) ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UrlMkSetSessionOption = Win32::API::More->new('urlmon',
'int UrlMkSetSessionOption(DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD dwReserved)');
# my $ret = $UrlMkSetSessionOption->Call($dwOption, $pBuffer, $dwBufferLength, $dwReserved);
# dwOption : DWORD -> DWORD
# pBuffer : void* optional -> LPVOID
# dwBufferLength : DWORD -> DWORD
# dwReserved : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。