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

CreateUri

関数
URI文字列を解析してIUriオブジェクトを作成する。
DLLURLMON.dll呼出規約winapi

シグネチャ

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

HRESULT CreateUri(
    LPCWSTR pwzURI,
    URI_CREATE_FLAGS dwFlags,
    UINT_PTR dwReserved,   // optional
    IUri** ppURI
);

パラメーター

名前方向
pwzURILPCWSTRin
dwFlagsURI_CREATE_FLAGSin
dwReservedUINT_PTRoptional
ppURIIUri**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CreateUri(
    LPCWSTR pwzURI,
    URI_CREATE_FLAGS dwFlags,
    UINT_PTR dwReserved,   // optional
    IUri** ppURI
);
[DllImport("URLMON.dll", ExactSpelling = true)]
static extern int CreateUri(
    [MarshalAs(UnmanagedType.LPWStr)] string pwzURI,   // LPCWSTR
    uint dwFlags,   // URI_CREATE_FLAGS
    UIntPtr dwReserved,   // UINT_PTR optional
    IntPtr ppURI   // IUri** out
);
<DllImport("URLMON.dll", ExactSpelling:=True)>
Public Shared Function CreateUri(
    <MarshalAs(UnmanagedType.LPWStr)> pwzURI As String,   ' LPCWSTR
    dwFlags As UInteger,   ' URI_CREATE_FLAGS
    dwReserved As UIntPtr,   ' UINT_PTR optional
    ppURI As IntPtr   ' IUri** out
) As Integer
End Function
' pwzURI : LPCWSTR
' dwFlags : URI_CREATE_FLAGS
' dwReserved : UINT_PTR optional
' ppURI : IUri** out
Declare PtrSafe Function CreateUri Lib "urlmon" ( _
    ByVal pwzURI As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal dwReserved As LongPtr, _
    ByVal ppURI As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateUri = ctypes.windll.urlmon.CreateUri
CreateUri.restype = ctypes.c_int
CreateUri.argtypes = [
    wintypes.LPCWSTR,  # pwzURI : LPCWSTR
    wintypes.DWORD,  # dwFlags : URI_CREATE_FLAGS
    ctypes.c_size_t,  # dwReserved : UINT_PTR optional
    ctypes.c_void_p,  # ppURI : IUri** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('URLMON.dll')
CreateUri = Fiddle::Function.new(
  lib['CreateUri'],
  [
    Fiddle::TYPE_VOIDP,  # pwzURI : LPCWSTR
    -Fiddle::TYPE_INT,  # dwFlags : URI_CREATE_FLAGS
    Fiddle::TYPE_UINTPTR_T,  # dwReserved : UINT_PTR optional
    Fiddle::TYPE_VOIDP,  # ppURI : IUri** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "urlmon")]
extern "system" {
    fn CreateUri(
        pwzURI: *const u16,  // LPCWSTR
        dwFlags: u32,  // URI_CREATE_FLAGS
        dwReserved: usize,  // UINT_PTR optional
        ppURI: *mut *mut core::ffi::c_void  // IUri** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("URLMON.dll")]
public static extern int CreateUri([MarshalAs(UnmanagedType.LPWStr)] string pwzURI, uint dwFlags, UIntPtr dwReserved, IntPtr ppURI);
"@
$api = Add-Type -MemberDefinition $sig -Name 'URLMON_CreateUri' -Namespace Win32 -PassThru
# $api::CreateUri(pwzURI, dwFlags, dwReserved, ppURI)
#uselib "URLMON.dll"
#func global CreateUri "CreateUri" sptr, sptr, sptr, sptr
; CreateUri pwzURI, dwFlags, dwReserved, ppURI   ; 戻り値は stat
; pwzURI : LPCWSTR -> "sptr"
; dwFlags : URI_CREATE_FLAGS -> "sptr"
; dwReserved : UINT_PTR optional -> "sptr"
; ppURI : IUri** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "URLMON.dll"
#cfunc global CreateUri "CreateUri" wstr, int, sptr, sptr
; res = CreateUri(pwzURI, dwFlags, dwReserved, ppURI)
; pwzURI : LPCWSTR -> "wstr"
; dwFlags : URI_CREATE_FLAGS -> "int"
; dwReserved : UINT_PTR optional -> "sptr"
; ppURI : IUri** out -> "sptr"
; HRESULT CreateUri(LPCWSTR pwzURI, URI_CREATE_FLAGS dwFlags, UINT_PTR dwReserved, IUri** ppURI)
#uselib "URLMON.dll"
#cfunc global CreateUri "CreateUri" wstr, int, intptr, intptr
; res = CreateUri(pwzURI, dwFlags, dwReserved, ppURI)
; pwzURI : LPCWSTR -> "wstr"
; dwFlags : URI_CREATE_FLAGS -> "int"
; dwReserved : UINT_PTR optional -> "intptr"
; ppURI : IUri** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	urlmon = windows.NewLazySystemDLL("URLMON.dll")
	procCreateUri = urlmon.NewProc("CreateUri")
)

// pwzURI (LPCWSTR), dwFlags (URI_CREATE_FLAGS), dwReserved (UINT_PTR optional), ppURI (IUri** out)
r1, _, err := procCreateUri.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzURI))),
	uintptr(dwFlags),
	uintptr(dwReserved),
	uintptr(ppURI),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CreateUri(
  pwzURI: PWideChar;   // LPCWSTR
  dwFlags: DWORD;   // URI_CREATE_FLAGS
  dwReserved: NativeUInt;   // UINT_PTR optional
  ppURI: Pointer   // IUri** out
): Integer; stdcall;
  external 'URLMON.dll' name 'CreateUri';
result := DllCall("URLMON\CreateUri"
    , "WStr", pwzURI   ; LPCWSTR
    , "UInt", dwFlags   ; URI_CREATE_FLAGS
    , "UPtr", dwReserved   ; UINT_PTR optional
    , "Ptr", ppURI   ; IUri** out
    , "Int")   ; return: HRESULT
●CreateUri(pwzURI, dwFlags, dwReserved, ppURI) = DLL("URLMON.dll", "int CreateUri(char*, dword, int, void*)")
# 呼び出し: CreateUri(pwzURI, dwFlags, dwReserved, ppURI)
# pwzURI : LPCWSTR -> "char*"
# dwFlags : URI_CREATE_FLAGS -> "dword"
# dwReserved : UINT_PTR optional -> "int"
# ppURI : IUri** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。