PathAllocCombine
関数2つのパスを連結し結果バッファを自動確保する。
シグネチャ
// api-ms-win-core-path-l1-1-0.dll
#include <windows.h>
HRESULT PathAllocCombine(
LPCWSTR pszPathIn, // optional
LPCWSTR pszMore, // optional
PATHCCH_OPTIONS dwFlags,
LPWSTR* ppszPathOut
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszPathIn | LPCWSTR | inoptional |
| pszMore | LPCWSTR | inoptional |
| dwFlags | PATHCCH_OPTIONS | in |
| ppszPathOut | LPWSTR* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// api-ms-win-core-path-l1-1-0.dll
#include <windows.h>
HRESULT PathAllocCombine(
LPCWSTR pszPathIn, // optional
LPCWSTR pszMore, // optional
PATHCCH_OPTIONS dwFlags,
LPWSTR* ppszPathOut
);[DllImport("api-ms-win-core-path-l1-1-0.dll", ExactSpelling = true)]
static extern int PathAllocCombine(
[MarshalAs(UnmanagedType.LPWStr)] string pszPathIn, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string pszMore, // LPCWSTR optional
uint dwFlags, // PATHCCH_OPTIONS
IntPtr ppszPathOut // LPWSTR* out
);<DllImport("api-ms-win-core-path-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function PathAllocCombine(
<MarshalAs(UnmanagedType.LPWStr)> pszPathIn As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> pszMore As String, ' LPCWSTR optional
dwFlags As UInteger, ' PATHCCH_OPTIONS
ppszPathOut As IntPtr ' LPWSTR* out
) As Integer
End Function' pszPathIn : LPCWSTR optional
' pszMore : LPCWSTR optional
' dwFlags : PATHCCH_OPTIONS
' ppszPathOut : LPWSTR* out
Declare PtrSafe Function PathAllocCombine Lib "api-ms-win-core-path-l1-1-0" ( _
ByVal pszPathIn As LongPtr, _
ByVal pszMore As LongPtr, _
ByVal dwFlags As Long, _
ByVal ppszPathOut As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PathAllocCombine = ctypes.windll.LoadLibrary("api-ms-win-core-path-l1-1-0.dll").PathAllocCombine
PathAllocCombine.restype = ctypes.c_int
PathAllocCombine.argtypes = [
wintypes.LPCWSTR, # pszPathIn : LPCWSTR optional
wintypes.LPCWSTR, # pszMore : LPCWSTR optional
wintypes.DWORD, # dwFlags : PATHCCH_OPTIONS
ctypes.c_void_p, # ppszPathOut : LPWSTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-path-l1-1-0.dll')
PathAllocCombine = Fiddle::Function.new(
lib['PathAllocCombine'],
[
Fiddle::TYPE_VOIDP, # pszPathIn : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pszMore : LPCWSTR optional
-Fiddle::TYPE_INT, # dwFlags : PATHCCH_OPTIONS
Fiddle::TYPE_VOIDP, # ppszPathOut : LPWSTR* out
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-path-l1-1-0")]
extern "system" {
fn PathAllocCombine(
pszPathIn: *const u16, // LPCWSTR optional
pszMore: *const u16, // LPCWSTR optional
dwFlags: u32, // PATHCCH_OPTIONS
ppszPathOut: *mut *mut u16 // LPWSTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-path-l1-1-0.dll")]
public static extern int PathAllocCombine([MarshalAs(UnmanagedType.LPWStr)] string pszPathIn, [MarshalAs(UnmanagedType.LPWStr)] string pszMore, uint dwFlags, IntPtr ppszPathOut);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-path-l1-1-0_PathAllocCombine' -Namespace Win32 -PassThru
# $api::PathAllocCombine(pszPathIn, pszMore, dwFlags, ppszPathOut)#uselib "api-ms-win-core-path-l1-1-0.dll"
#func global PathAllocCombine "PathAllocCombine" sptr, sptr, sptr, sptr
; PathAllocCombine pszPathIn, pszMore, dwFlags, varptr(ppszPathOut) ; 戻り値は stat
; pszPathIn : LPCWSTR optional -> "sptr"
; pszMore : LPCWSTR optional -> "sptr"
; dwFlags : PATHCCH_OPTIONS -> "sptr"
; ppszPathOut : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-path-l1-1-0.dll" #cfunc global PathAllocCombine "PathAllocCombine" wstr, wstr, int, var ; res = PathAllocCombine(pszPathIn, pszMore, dwFlags, ppszPathOut) ; pszPathIn : LPCWSTR optional -> "wstr" ; pszMore : LPCWSTR optional -> "wstr" ; dwFlags : PATHCCH_OPTIONS -> "int" ; ppszPathOut : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-core-path-l1-1-0.dll" #cfunc global PathAllocCombine "PathAllocCombine" wstr, wstr, int, sptr ; res = PathAllocCombine(pszPathIn, pszMore, dwFlags, varptr(ppszPathOut)) ; pszPathIn : LPCWSTR optional -> "wstr" ; pszMore : LPCWSTR optional -> "wstr" ; dwFlags : PATHCCH_OPTIONS -> "int" ; ppszPathOut : LPWSTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT PathAllocCombine(LPCWSTR pszPathIn, LPCWSTR pszMore, PATHCCH_OPTIONS dwFlags, LPWSTR* ppszPathOut) #uselib "api-ms-win-core-path-l1-1-0.dll" #cfunc global PathAllocCombine "PathAllocCombine" wstr, wstr, int, var ; res = PathAllocCombine(pszPathIn, pszMore, dwFlags, ppszPathOut) ; pszPathIn : LPCWSTR optional -> "wstr" ; pszMore : LPCWSTR optional -> "wstr" ; dwFlags : PATHCCH_OPTIONS -> "int" ; ppszPathOut : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT PathAllocCombine(LPCWSTR pszPathIn, LPCWSTR pszMore, PATHCCH_OPTIONS dwFlags, LPWSTR* ppszPathOut) #uselib "api-ms-win-core-path-l1-1-0.dll" #cfunc global PathAllocCombine "PathAllocCombine" wstr, wstr, int, intptr ; res = PathAllocCombine(pszPathIn, pszMore, dwFlags, varptr(ppszPathOut)) ; pszPathIn : LPCWSTR optional -> "wstr" ; pszMore : LPCWSTR optional -> "wstr" ; dwFlags : PATHCCH_OPTIONS -> "int" ; ppszPathOut : LPWSTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_path_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-path-l1-1-0.dll")
procPathAllocCombine = api_ms_win_core_path_l1_1_0.NewProc("PathAllocCombine")
)
// pszPathIn (LPCWSTR optional), pszMore (LPCWSTR optional), dwFlags (PATHCCH_OPTIONS), ppszPathOut (LPWSTR* out)
r1, _, err := procPathAllocCombine.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPathIn))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszMore))),
uintptr(dwFlags),
uintptr(ppszPathOut),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction PathAllocCombine(
pszPathIn: PWideChar; // LPCWSTR optional
pszMore: PWideChar; // LPCWSTR optional
dwFlags: DWORD; // PATHCCH_OPTIONS
ppszPathOut: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'api-ms-win-core-path-l1-1-0.dll' name 'PathAllocCombine';result := DllCall("api-ms-win-core-path-l1-1-0\PathAllocCombine"
, "WStr", pszPathIn ; LPCWSTR optional
, "WStr", pszMore ; LPCWSTR optional
, "UInt", dwFlags ; PATHCCH_OPTIONS
, "Ptr", ppszPathOut ; LPWSTR* out
, "Int") ; return: HRESULT●PathAllocCombine(pszPathIn, pszMore, dwFlags, ppszPathOut) = DLL("api-ms-win-core-path-l1-1-0.dll", "int PathAllocCombine(char*, char*, dword, void*)")
# 呼び出し: PathAllocCombine(pszPathIn, pszMore, dwFlags, ppszPathOut)
# pszPathIn : LPCWSTR optional -> "char*"
# pszMore : LPCWSTR optional -> "char*"
# dwFlags : PATHCCH_OPTIONS -> "dword"
# ppszPathOut : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。