Win32 API 日本語リファレンス
ホームSystem.Com.Urlmon › UrlMkGetSessionOption

UrlMkGetSessionOption

関数
URLモニカーセッションのオプション値を取得する。
DLLurlmon.dll呼出規約winapi

シグネチャ

// urlmon.dll
#include <windows.h>

HRESULT UrlMkGetSessionOption(
    DWORD dwOption,
    void* pBuffer,   // optional
    DWORD dwBufferLength,
    DWORD* pdwBufferLengthOut,
    DWORD dwReserved   // optional
);

パラメーター

名前方向説明
dwOptionDWORDin取得するセッションオプションの識別子。URLMON_OPTION_*を指定する。
pBuffervoid*outoptional取得値を書き込む出力バッファへのポインタ。
dwBufferLengthDWORDinpBufferの容量(バイト単位)。
pdwBufferLengthOutDWORD*out実際に書き込まれたバイト数を受け取る出力ポインタ。NULL可。
dwReservedDWORDoptional予約パラメータ。0を指定する必要がある。

戻り値の型: HRESULT

各言語での呼び出し定義

// urlmon.dll
#include <windows.h>

HRESULT UrlMkGetSessionOption(
    DWORD dwOption,
    void* pBuffer,   // optional
    DWORD dwBufferLength,
    DWORD* pdwBufferLengthOut,
    DWORD dwReserved   // optional
);
[DllImport("urlmon.dll", ExactSpelling = true)]
static extern int UrlMkGetSessionOption(
    uint dwOption,   // DWORD
    IntPtr pBuffer,   // void* optional, out
    uint dwBufferLength,   // DWORD
    out uint pdwBufferLengthOut,   // DWORD* out
    uint dwReserved   // DWORD optional
);
<DllImport("urlmon.dll", ExactSpelling:=True)>
Public Shared Function UrlMkGetSessionOption(
    dwOption As UInteger,   ' DWORD
    pBuffer As IntPtr,   ' void* optional, out
    dwBufferLength As UInteger,   ' DWORD
    <Out> ByRef pdwBufferLengthOut As UInteger,   ' DWORD* out
    dwReserved As UInteger   ' DWORD optional
) As Integer
End Function
' dwOption : DWORD
' pBuffer : void* optional, out
' dwBufferLength : DWORD
' pdwBufferLengthOut : DWORD* out
' dwReserved : DWORD optional
Declare PtrSafe Function UrlMkGetSessionOption Lib "urlmon" ( _
    ByVal dwOption As Long, _
    ByVal pBuffer As LongPtr, _
    ByVal dwBufferLength As Long, _
    ByRef pdwBufferLengthOut 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

UrlMkGetSessionOption = ctypes.windll.urlmon.UrlMkGetSessionOption
UrlMkGetSessionOption.restype = ctypes.c_int
UrlMkGetSessionOption.argtypes = [
    wintypes.DWORD,  # dwOption : DWORD
    ctypes.POINTER(None),  # pBuffer : void* optional, out
    wintypes.DWORD,  # dwBufferLength : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pdwBufferLengthOut : DWORD* out
    wintypes.DWORD,  # dwReserved : DWORD optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('urlmon.dll')
UrlMkGetSessionOption = Fiddle::Function.new(
  lib['UrlMkGetSessionOption'],
  [
    -Fiddle::TYPE_INT,  # dwOption : DWORD
    Fiddle::TYPE_VOIDP,  # pBuffer : void* optional, out
    -Fiddle::TYPE_INT,  # dwBufferLength : DWORD
    Fiddle::TYPE_VOIDP,  # pdwBufferLengthOut : DWORD* out
    -Fiddle::TYPE_INT,  # dwReserved : DWORD optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "urlmon")]
extern "system" {
    fn UrlMkGetSessionOption(
        dwOption: u32,  // DWORD
        pBuffer: *mut (),  // void* optional, out
        dwBufferLength: u32,  // DWORD
        pdwBufferLengthOut: *mut u32,  // DWORD* out
        dwReserved: u32  // DWORD optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("urlmon.dll")]
public static extern int UrlMkGetSessionOption(uint dwOption, IntPtr pBuffer, uint dwBufferLength, out uint pdwBufferLengthOut, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'urlmon_UrlMkGetSessionOption' -Namespace Win32 -PassThru
# $api::UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved)
#uselib "urlmon.dll"
#func global UrlMkGetSessionOption "UrlMkGetSessionOption" sptr, sptr, sptr, sptr, sptr
; UrlMkGetSessionOption dwOption, pBuffer, dwBufferLength, varptr(pdwBufferLengthOut), dwReserved   ; 戻り値は stat
; dwOption : DWORD -> "sptr"
; pBuffer : void* optional, out -> "sptr"
; dwBufferLength : DWORD -> "sptr"
; pdwBufferLengthOut : DWORD* out -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "urlmon.dll"
#cfunc global UrlMkGetSessionOption "UrlMkGetSessionOption" int, sptr, int, var, int
; res = UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved)
; dwOption : DWORD -> "int"
; pBuffer : void* optional, out -> "sptr"
; dwBufferLength : DWORD -> "int"
; pdwBufferLengthOut : DWORD* out -> "var"
; dwReserved : DWORD optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT UrlMkGetSessionOption(DWORD dwOption, void* pBuffer, DWORD dwBufferLength, DWORD* pdwBufferLengthOut, DWORD dwReserved)
#uselib "urlmon.dll"
#cfunc global UrlMkGetSessionOption "UrlMkGetSessionOption" int, intptr, int, var, int
; res = UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved)
; dwOption : DWORD -> "int"
; pBuffer : void* optional, out -> "intptr"
; dwBufferLength : DWORD -> "int"
; pdwBufferLengthOut : DWORD* out -> "var"
; dwReserved : DWORD optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	urlmon = windows.NewLazySystemDLL("urlmon.dll")
	procUrlMkGetSessionOption = urlmon.NewProc("UrlMkGetSessionOption")
)

// dwOption (DWORD), pBuffer (void* optional, out), dwBufferLength (DWORD), pdwBufferLengthOut (DWORD* out), dwReserved (DWORD optional)
r1, _, err := procUrlMkGetSessionOption.Call(
	uintptr(dwOption),
	uintptr(pBuffer),
	uintptr(dwBufferLength),
	uintptr(pdwBufferLengthOut),
	uintptr(dwReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function UrlMkGetSessionOption(
  dwOption: DWORD;   // DWORD
  pBuffer: Pointer;   // void* optional, out
  dwBufferLength: DWORD;   // DWORD
  pdwBufferLengthOut: Pointer;   // DWORD* out
  dwReserved: DWORD   // DWORD optional
): Integer; stdcall;
  external 'urlmon.dll' name 'UrlMkGetSessionOption';
result := DllCall("urlmon\UrlMkGetSessionOption"
    , "UInt", dwOption   ; DWORD
    , "Ptr", pBuffer   ; void* optional, out
    , "UInt", dwBufferLength   ; DWORD
    , "Ptr", pdwBufferLengthOut   ; DWORD* out
    , "UInt", dwReserved   ; DWORD optional
    , "Int")   ; return: HRESULT
●UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved) = DLL("urlmon.dll", "int UrlMkGetSessionOption(dword, void*, dword, void*, dword)")
# 呼び出し: UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved)
# dwOption : DWORD -> "dword"
# pBuffer : void* optional, out -> "void*"
# dwBufferLength : DWORD -> "dword"
# pdwBufferLengthOut : DWORD* out -> "void*"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "urlmon" fn UrlMkGetSessionOption(
    dwOption: u32, // DWORD
    pBuffer: ?*anyopaque, // void* optional, out
    dwBufferLength: u32, // DWORD
    pdwBufferLengthOut: [*c]u32, // DWORD* out
    dwReserved: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) i32;
proc UrlMkGetSessionOption(
    dwOption: uint32,  # DWORD
    pBuffer: pointer,  # void* optional, out
    dwBufferLength: uint32,  # DWORD
    pdwBufferLengthOut: ptr uint32,  # DWORD* out
    dwReserved: uint32  # DWORD optional
): int32 {.importc: "UrlMkGetSessionOption", stdcall, dynlib: "urlmon.dll".}
pragma(lib, "urlmon");
extern(Windows)
int UrlMkGetSessionOption(
    uint dwOption,   // DWORD
    void* pBuffer,   // void* optional, out
    uint dwBufferLength,   // DWORD
    uint* pdwBufferLengthOut,   // DWORD* out
    uint dwReserved   // DWORD optional
);
ccall((:UrlMkGetSessionOption, "urlmon.dll"), stdcall, Int32,
      (UInt32, Ptr{Cvoid}, UInt32, Ptr{UInt32}, UInt32),
      dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved)
# dwOption : DWORD -> UInt32
# pBuffer : void* optional, out -> Ptr{Cvoid}
# dwBufferLength : DWORD -> UInt32
# pdwBufferLengthOut : DWORD* out -> Ptr{UInt32}
# dwReserved : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t UrlMkGetSessionOption(
    uint32_t dwOption,
    void* pBuffer,
    uint32_t dwBufferLength,
    uint32_t* pdwBufferLengthOut,
    uint32_t dwReserved);
]]
local urlmon = ffi.load("urlmon")
-- urlmon.UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved)
-- dwOption : DWORD
-- pBuffer : void* optional, out
-- dwBufferLength : DWORD
-- pdwBufferLengthOut : DWORD* out
-- dwReserved : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('urlmon.dll');
const UrlMkGetSessionOption = lib.func('__stdcall', 'UrlMkGetSessionOption', 'int32_t', ['uint32_t', 'void *', 'uint32_t', 'uint32_t *', 'uint32_t']);
// UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved)
// dwOption : DWORD -> 'uint32_t'
// pBuffer : void* optional, out -> 'void *'
// dwBufferLength : DWORD -> 'uint32_t'
// pdwBufferLengthOut : DWORD* out -> 'uint32_t *'
// dwReserved : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("urlmon.dll", {
  UrlMkGetSessionOption: { parameters: ["u32", "pointer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved)
// dwOption : DWORD -> "u32"
// pBuffer : void* optional, out -> "pointer"
// dwBufferLength : DWORD -> "u32"
// pdwBufferLengthOut : DWORD* out -> "pointer"
// dwReserved : DWORD optional -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t UrlMkGetSessionOption(
    uint32_t dwOption,
    void* pBuffer,
    uint32_t dwBufferLength,
    uint32_t* pdwBufferLengthOut,
    uint32_t dwReserved);
C, "urlmon.dll");
// $ffi->UrlMkGetSessionOption(dwOption, pBuffer, dwBufferLength, pdwBufferLengthOut, dwReserved);
// dwOption : DWORD
// pBuffer : void* optional, out
// dwBufferLength : DWORD
// pdwBufferLengthOut : DWORD* out
// 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 UrlMkGetSessionOption(
        int dwOption,   // DWORD
        Pointer pBuffer,   // void* optional, out
        int dwBufferLength,   // DWORD
        IntByReference pdwBufferLengthOut,   // DWORD* out
        int dwReserved   // DWORD optional
    );
}
@[Link("urlmon")]
lib Liburlmon
  fun UrlMkGetSessionOption = UrlMkGetSessionOption(
    dwOption : UInt32,   # DWORD
    pBuffer : Void*,   # void* optional, out
    dwBufferLength : UInt32,   # DWORD
    pdwBufferLengthOut : UInt32*,   # DWORD* out
    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 UrlMkGetSessionOptionNative = Int32 Function(Uint32, Pointer<Void>, Uint32, Pointer<Uint32>, Uint32);
typedef UrlMkGetSessionOptionDart = int Function(int, Pointer<Void>, int, Pointer<Uint32>, int);
final UrlMkGetSessionOption = DynamicLibrary.open('urlmon.dll')
    .lookupFunction<UrlMkGetSessionOptionNative, UrlMkGetSessionOptionDart>('UrlMkGetSessionOption');
// dwOption : DWORD -> Uint32
// pBuffer : void* optional, out -> Pointer<Void>
// dwBufferLength : DWORD -> Uint32
// pdwBufferLengthOut : DWORD* out -> Pointer<Uint32>
// dwReserved : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function UrlMkGetSessionOption(
  dwOption: DWORD;   // DWORD
  pBuffer: Pointer;   // void* optional, out
  dwBufferLength: DWORD;   // DWORD
  pdwBufferLengthOut: Pointer;   // DWORD* out
  dwReserved: DWORD   // DWORD optional
): Integer; stdcall;
  external 'urlmon.dll' name 'UrlMkGetSessionOption';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "UrlMkGetSessionOption"
  c_UrlMkGetSessionOption :: Word32 -> Ptr () -> Word32 -> Ptr Word32 -> Word32 -> IO Int32
-- dwOption : DWORD -> Word32
-- pBuffer : void* optional, out -> Ptr ()
-- dwBufferLength : DWORD -> Word32
-- pdwBufferLengthOut : DWORD* out -> Ptr Word32
-- dwReserved : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let urlmkgetsessionoption =
  foreign "UrlMkGetSessionOption"
    (uint32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> uint32_t @-> returning int32_t)
(* dwOption : DWORD -> uint32_t *)
(* pBuffer : void* optional, out -> (ptr void) *)
(* dwBufferLength : DWORD -> uint32_t *)
(* pdwBufferLengthOut : DWORD* out -> (ptr 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 ("UrlMkGetSessionOption" url-mk-get-session-option :convention :stdcall) :int32
  (dw-option :uint32)   ; DWORD
  (p-buffer :pointer)   ; void* optional, out
  (dw-buffer-length :uint32)   ; DWORD
  (pdw-buffer-length-out :pointer)   ; DWORD* out
  (dw-reserved :uint32))   ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $UrlMkGetSessionOption = Win32::API::More->new('urlmon',
    'int UrlMkGetSessionOption(DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, LPVOID pdwBufferLengthOut, DWORD dwReserved)');
# my $ret = $UrlMkGetSessionOption->Call($dwOption, $pBuffer, $dwBufferLength, $pdwBufferLengthOut, $dwReserved);
# dwOption : DWORD -> DWORD
# pBuffer : void* optional, out -> LPVOID
# dwBufferLength : DWORD -> DWORD
# pdwBufferLengthOut : DWORD* out -> LPVOID
# dwReserved : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。