Win32 API 日本語リファレンス
ホームNetworking.WinInet › InternetCombineUrlA

InternetCombineUrlA

関数
基準URLと相対URLを結合して絶対URLを生成する(ANSI)。
DLLWININET.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL InternetCombineUrlA(
    LPCSTR lpszBaseUrl,
    LPCSTR lpszRelativeUrl,
    LPSTR lpszBuffer,
    DWORD* lpdwBufferLength,
    DWORD dwFlags
);

パラメーター

名前方向
lpszBaseUrlLPCSTRin
lpszRelativeUrlLPCSTRin
lpszBufferLPSTRout
lpdwBufferLengthDWORD*inout
dwFlagsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL InternetCombineUrlA(
    LPCSTR lpszBaseUrl,
    LPCSTR lpszRelativeUrl,
    LPSTR lpszBuffer,
    DWORD* lpdwBufferLength,
    DWORD dwFlags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool InternetCombineUrlA(
    [MarshalAs(UnmanagedType.LPStr)] string lpszBaseUrl,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string lpszRelativeUrl,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszBuffer,   // LPSTR out
    ref uint lpdwBufferLength,   // DWORD* in/out
    uint dwFlags   // DWORD
);
<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function InternetCombineUrlA(
    <MarshalAs(UnmanagedType.LPStr)> lpszBaseUrl As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpszRelativeUrl As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpszBuffer As System.Text.StringBuilder,   ' LPSTR out
    ByRef lpdwBufferLength As UInteger,   ' DWORD* in/out
    dwFlags As UInteger   ' DWORD
) As Boolean
End Function
' lpszBaseUrl : LPCSTR
' lpszRelativeUrl : LPCSTR
' lpszBuffer : LPSTR out
' lpdwBufferLength : DWORD* in/out
' dwFlags : DWORD
Declare PtrSafe Function InternetCombineUrlA Lib "wininet" ( _
    ByVal lpszBaseUrl As String, _
    ByVal lpszRelativeUrl As String, _
    ByVal lpszBuffer As String, _
    ByRef lpdwBufferLength 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

InternetCombineUrlA = ctypes.windll.wininet.InternetCombineUrlA
InternetCombineUrlA.restype = wintypes.BOOL
InternetCombineUrlA.argtypes = [
    wintypes.LPCSTR,  # lpszBaseUrl : LPCSTR
    wintypes.LPCSTR,  # lpszRelativeUrl : LPCSTR
    wintypes.LPSTR,  # lpszBuffer : LPSTR out
    ctypes.POINTER(wintypes.DWORD),  # lpdwBufferLength : DWORD* in/out
    wintypes.DWORD,  # dwFlags : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
InternetCombineUrlA = Fiddle::Function.new(
  lib['InternetCombineUrlA'],
  [
    Fiddle::TYPE_VOIDP,  # lpszBaseUrl : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpszRelativeUrl : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpszBuffer : LPSTR out
    Fiddle::TYPE_VOIDP,  # lpdwBufferLength : DWORD* in/out
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "wininet")]
extern "system" {
    fn InternetCombineUrlA(
        lpszBaseUrl: *const u8,  // LPCSTR
        lpszRelativeUrl: *const u8,  // LPCSTR
        lpszBuffer: *mut u8,  // LPSTR out
        lpdwBufferLength: *mut u32,  // DWORD* in/out
        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, SetLastError = true)]
public static extern bool InternetCombineUrlA([MarshalAs(UnmanagedType.LPStr)] string lpszBaseUrl, [MarshalAs(UnmanagedType.LPStr)] string lpszRelativeUrl, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszBuffer, ref uint lpdwBufferLength, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetCombineUrlA' -Namespace Win32 -PassThru
# $api::InternetCombineUrlA(lpszBaseUrl, lpszRelativeUrl, lpszBuffer, lpdwBufferLength, dwFlags)
#uselib "WININET.dll"
#func global InternetCombineUrlA "InternetCombineUrlA" sptr, sptr, sptr, sptr, sptr
; InternetCombineUrlA lpszBaseUrl, lpszRelativeUrl, varptr(lpszBuffer), varptr(lpdwBufferLength), dwFlags   ; 戻り値は stat
; lpszBaseUrl : LPCSTR -> "sptr"
; lpszRelativeUrl : LPCSTR -> "sptr"
; lpszBuffer : LPSTR out -> "sptr"
; lpdwBufferLength : DWORD* in/out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global InternetCombineUrlA "InternetCombineUrlA" str, str, var, var, int
; res = InternetCombineUrlA(lpszBaseUrl, lpszRelativeUrl, lpszBuffer, lpdwBufferLength, dwFlags)
; lpszBaseUrl : LPCSTR -> "str"
; lpszRelativeUrl : LPCSTR -> "str"
; lpszBuffer : LPSTR out -> "var"
; lpdwBufferLength : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL InternetCombineUrlA(LPCSTR lpszBaseUrl, LPCSTR lpszRelativeUrl, LPSTR lpszBuffer, DWORD* lpdwBufferLength, DWORD dwFlags)
#uselib "WININET.dll"
#cfunc global InternetCombineUrlA "InternetCombineUrlA" str, str, var, var, int
; res = InternetCombineUrlA(lpszBaseUrl, lpszRelativeUrl, lpszBuffer, lpdwBufferLength, dwFlags)
; lpszBaseUrl : LPCSTR -> "str"
; lpszRelativeUrl : LPCSTR -> "str"
; lpszBuffer : LPSTR out -> "var"
; lpdwBufferLength : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procInternetCombineUrlA = wininet.NewProc("InternetCombineUrlA")
)

// lpszBaseUrl (LPCSTR), lpszRelativeUrl (LPCSTR), lpszBuffer (LPSTR out), lpdwBufferLength (DWORD* in/out), dwFlags (DWORD)
r1, _, err := procInternetCombineUrlA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszBaseUrl))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszRelativeUrl))),
	uintptr(lpszBuffer),
	uintptr(lpdwBufferLength),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function InternetCombineUrlA(
  lpszBaseUrl: PAnsiChar;   // LPCSTR
  lpszRelativeUrl: PAnsiChar;   // LPCSTR
  lpszBuffer: PAnsiChar;   // LPSTR out
  lpdwBufferLength: Pointer;   // DWORD* in/out
  dwFlags: DWORD   // DWORD
): BOOL; stdcall;
  external 'WININET.dll' name 'InternetCombineUrlA';
result := DllCall("WININET\InternetCombineUrlA"
    , "AStr", lpszBaseUrl   ; LPCSTR
    , "AStr", lpszRelativeUrl   ; LPCSTR
    , "Ptr", lpszBuffer   ; LPSTR out
    , "Ptr", lpdwBufferLength   ; DWORD* in/out
    , "UInt", dwFlags   ; DWORD
    , "Int")   ; return: BOOL
●InternetCombineUrlA(lpszBaseUrl, lpszRelativeUrl, lpszBuffer, lpdwBufferLength, dwFlags) = DLL("WININET.dll", "bool InternetCombineUrlA(char*, char*, char*, void*, dword)")
# 呼び出し: InternetCombineUrlA(lpszBaseUrl, lpszRelativeUrl, lpszBuffer, lpdwBufferLength, dwFlags)
# lpszBaseUrl : LPCSTR -> "char*"
# lpszRelativeUrl : LPCSTR -> "char*"
# lpszBuffer : LPSTR out -> "char*"
# lpdwBufferLength : DWORD* in/out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。