Win32 API 日本語リファレンス
ホームUI.Shell › UrlCombineW

UrlCombineW

関数
基底URLと相対URLを連結し1つのURLを生成する。
DLLSHLWAPI.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHLWAPI.dll  (Unicode / -W)
#include <windows.h>

HRESULT UrlCombineW(
    LPCWSTR pszBase,
    LPCWSTR pszRelative,
    LPWSTR pszCombined,   // optional
    DWORD* pcchCombined,
    DWORD dwFlags
);

パラメーター

名前方向
pszBaseLPCWSTRin
pszRelativeLPCWSTRin
pszCombinedLPWSTRoutoptional
pcchCombinedDWORD*inout
dwFlagsDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

// SHLWAPI.dll  (Unicode / -W)
#include <windows.h>

HRESULT UrlCombineW(
    LPCWSTR pszBase,
    LPCWSTR pszRelative,
    LPWSTR pszCombined,   // optional
    DWORD* pcchCombined,
    DWORD dwFlags
);
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int UrlCombineW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszBase,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszRelative,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszCombined,   // LPWSTR optional, out
    ref uint pcchCombined,   // DWORD* in/out
    uint dwFlags   // DWORD
);
<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function UrlCombineW(
    <MarshalAs(UnmanagedType.LPWStr)> pszBase As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszRelative As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszCombined As System.Text.StringBuilder,   ' LPWSTR optional, out
    ByRef pcchCombined As UInteger,   ' DWORD* in/out
    dwFlags As UInteger   ' DWORD
) As Integer
End Function
' pszBase : LPCWSTR
' pszRelative : LPCWSTR
' pszCombined : LPWSTR optional, out
' pcchCombined : DWORD* in/out
' dwFlags : DWORD
Declare PtrSafe Function UrlCombineW Lib "shlwapi" ( _
    ByVal pszBase As LongPtr, _
    ByVal pszRelative As LongPtr, _
    ByVal pszCombined As LongPtr, _
    ByRef pcchCombined As Long, _
    ByVal dwFlags As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UrlCombineW = ctypes.windll.shlwapi.UrlCombineW
UrlCombineW.restype = ctypes.c_int
UrlCombineW.argtypes = [
    wintypes.LPCWSTR,  # pszBase : LPCWSTR
    wintypes.LPCWSTR,  # pszRelative : LPCWSTR
    wintypes.LPWSTR,  # pszCombined : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchCombined : DWORD* in/out
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
UrlCombineW = Fiddle::Function.new(
  lib['UrlCombineW'],
  [
    Fiddle::TYPE_VOIDP,  # pszBase : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszRelative : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszCombined : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchCombined : DWORD* in/out
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "shlwapi")]
extern "system" {
    fn UrlCombineW(
        pszBase: *const u16,  // LPCWSTR
        pszRelative: *const u16,  // LPCWSTR
        pszCombined: *mut u16,  // LPWSTR optional, out
        pcchCombined: *mut u32,  // DWORD* in/out
        dwFlags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern int UrlCombineW([MarshalAs(UnmanagedType.LPWStr)] string pszBase, [MarshalAs(UnmanagedType.LPWStr)] string pszRelative, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszCombined, ref uint pcchCombined, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_UrlCombineW' -Namespace Win32 -PassThru
# $api::UrlCombineW(pszBase, pszRelative, pszCombined, pcchCombined, dwFlags)
#uselib "SHLWAPI.dll"
#func global UrlCombineW "UrlCombineW" wptr, wptr, wptr, wptr, wptr
; UrlCombineW pszBase, pszRelative, varptr(pszCombined), varptr(pcchCombined), dwFlags   ; 戻り値は stat
; pszBase : LPCWSTR -> "wptr"
; pszRelative : LPCWSTR -> "wptr"
; pszCombined : LPWSTR optional, out -> "wptr"
; pcchCombined : DWORD* in/out -> "wptr"
; dwFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SHLWAPI.dll"
#cfunc global UrlCombineW "UrlCombineW" wstr, wstr, var, var, int
; res = UrlCombineW(pszBase, pszRelative, pszCombined, pcchCombined, dwFlags)
; pszBase : LPCWSTR -> "wstr"
; pszRelative : LPCWSTR -> "wstr"
; pszCombined : LPWSTR optional, out -> "var"
; pcchCombined : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, LPWSTR pszCombined, DWORD* pcchCombined, DWORD dwFlags)
#uselib "SHLWAPI.dll"
#cfunc global UrlCombineW "UrlCombineW" wstr, wstr, var, var, int
; res = UrlCombineW(pszBase, pszRelative, pszCombined, pcchCombined, dwFlags)
; pszBase : LPCWSTR -> "wstr"
; pszRelative : LPCWSTR -> "wstr"
; pszCombined : LPWSTR optional, out -> "var"
; pcchCombined : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procUrlCombineW = shlwapi.NewProc("UrlCombineW")
)

// pszBase (LPCWSTR), pszRelative (LPCWSTR), pszCombined (LPWSTR optional, out), pcchCombined (DWORD* in/out), dwFlags (DWORD)
r1, _, err := procUrlCombineW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszBase))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszRelative))),
	uintptr(pszCombined),
	uintptr(pcchCombined),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function UrlCombineW(
  pszBase: PWideChar;   // LPCWSTR
  pszRelative: PWideChar;   // LPCWSTR
  pszCombined: PWideChar;   // LPWSTR optional, out
  pcchCombined: Pointer;   // DWORD* in/out
  dwFlags: DWORD   // DWORD
): Integer; stdcall;
  external 'SHLWAPI.dll' name 'UrlCombineW';
result := DllCall("SHLWAPI\UrlCombineW"
    , "WStr", pszBase   ; LPCWSTR
    , "WStr", pszRelative   ; LPCWSTR
    , "Ptr", pszCombined   ; LPWSTR optional, out
    , "Ptr", pcchCombined   ; DWORD* in/out
    , "UInt", dwFlags   ; DWORD
    , "Int")   ; return: HRESULT
●UrlCombineW(pszBase, pszRelative, pszCombined, pcchCombined, dwFlags) = DLL("SHLWAPI.dll", "int UrlCombineW(char*, char*, char*, void*, dword)")
# 呼び出し: UrlCombineW(pszBase, pszRelative, pszCombined, pcchCombined, dwFlags)
# pszBase : LPCWSTR -> "char*"
# pszRelative : LPCWSTR -> "char*"
# pszCombined : LPWSTR optional, out -> "char*"
# pcchCombined : DWORD* in/out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。