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

PathCchAppendEx

関数
オプション指定でパス末尾に別のパスを追加する。
DLLapi-ms-win-core-path-l1-1-0.dll呼出規約winapi対応OSwindows8.0

シグネチャ

// api-ms-win-core-path-l1-1-0.dll
#include <windows.h>

HRESULT PathCchAppendEx(
    LPWSTR pszPath,
    UINT_PTR cchPath,
    LPCWSTR pszMore,   // optional
    PATHCCH_OPTIONS dwFlags
);

パラメーター

名前方向
pszPathLPWSTRinout
cchPathUINT_PTRin
pszMoreLPCWSTRinoptional
dwFlagsPATHCCH_OPTIONSin

戻り値の型: HRESULT

各言語での呼び出し定義

// api-ms-win-core-path-l1-1-0.dll
#include <windows.h>

HRESULT PathCchAppendEx(
    LPWSTR pszPath,
    UINT_PTR cchPath,
    LPCWSTR pszMore,   // optional
    PATHCCH_OPTIONS dwFlags
);
[DllImport("api-ms-win-core-path-l1-1-0.dll", ExactSpelling = true)]
static extern int PathCchAppendEx(
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszPath,   // LPWSTR in/out
    UIntPtr cchPath,   // UINT_PTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszMore,   // LPCWSTR optional
    uint dwFlags   // PATHCCH_OPTIONS
);
<DllImport("api-ms-win-core-path-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function PathCchAppendEx(
    <MarshalAs(UnmanagedType.LPWStr)> pszPath As System.Text.StringBuilder,   ' LPWSTR in/out
    cchPath As UIntPtr,   ' UINT_PTR
    <MarshalAs(UnmanagedType.LPWStr)> pszMore As String,   ' LPCWSTR optional
    dwFlags As UInteger   ' PATHCCH_OPTIONS
) As Integer
End Function
' pszPath : LPWSTR in/out
' cchPath : UINT_PTR
' pszMore : LPCWSTR optional
' dwFlags : PATHCCH_OPTIONS
Declare PtrSafe Function PathCchAppendEx Lib "api-ms-win-core-path-l1-1-0" ( _
    ByVal pszPath As LongPtr, _
    ByVal cchPath As LongPtr, _
    ByVal pszMore As LongPtr, _
    ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PathCchAppendEx = ctypes.windll.LoadLibrary("api-ms-win-core-path-l1-1-0.dll").PathCchAppendEx
PathCchAppendEx.restype = ctypes.c_int
PathCchAppendEx.argtypes = [
    wintypes.LPWSTR,  # pszPath : LPWSTR in/out
    ctypes.c_size_t,  # cchPath : UINT_PTR
    wintypes.LPCWSTR,  # pszMore : LPCWSTR optional
    wintypes.DWORD,  # dwFlags : PATHCCH_OPTIONS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-path-l1-1-0.dll')
PathCchAppendEx = Fiddle::Function.new(
  lib['PathCchAppendEx'],
  [
    Fiddle::TYPE_VOIDP,  # pszPath : LPWSTR in/out
    Fiddle::TYPE_UINTPTR_T,  # cchPath : UINT_PTR
    Fiddle::TYPE_VOIDP,  # pszMore : LPCWSTR optional
    -Fiddle::TYPE_INT,  # dwFlags : PATHCCH_OPTIONS
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-path-l1-1-0")]
extern "system" {
    fn PathCchAppendEx(
        pszPath: *mut u16,  // LPWSTR in/out
        cchPath: usize,  // UINT_PTR
        pszMore: *const u16,  // LPCWSTR optional
        dwFlags: u32  // PATHCCH_OPTIONS
    ) -> 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 PathCchAppendEx([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszPath, UIntPtr cchPath, [MarshalAs(UnmanagedType.LPWStr)] string pszMore, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-path-l1-1-0_PathCchAppendEx' -Namespace Win32 -PassThru
# $api::PathCchAppendEx(pszPath, cchPath, pszMore, dwFlags)
#uselib "api-ms-win-core-path-l1-1-0.dll"
#func global PathCchAppendEx "PathCchAppendEx" sptr, sptr, sptr, sptr
; PathCchAppendEx varptr(pszPath), cchPath, pszMore, dwFlags   ; 戻り値は stat
; pszPath : LPWSTR in/out -> "sptr"
; cchPath : UINT_PTR -> "sptr"
; pszMore : LPCWSTR optional -> "sptr"
; dwFlags : PATHCCH_OPTIONS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "api-ms-win-core-path-l1-1-0.dll"
#cfunc global PathCchAppendEx "PathCchAppendEx" var, sptr, wstr, int
; res = PathCchAppendEx(pszPath, cchPath, pszMore, dwFlags)
; pszPath : LPWSTR in/out -> "var"
; cchPath : UINT_PTR -> "sptr"
; pszMore : LPCWSTR optional -> "wstr"
; dwFlags : PATHCCH_OPTIONS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT PathCchAppendEx(LPWSTR pszPath, UINT_PTR cchPath, LPCWSTR pszMore, PATHCCH_OPTIONS dwFlags)
#uselib "api-ms-win-core-path-l1-1-0.dll"
#cfunc global PathCchAppendEx "PathCchAppendEx" var, intptr, wstr, int
; res = PathCchAppendEx(pszPath, cchPath, pszMore, dwFlags)
; pszPath : LPWSTR in/out -> "var"
; cchPath : UINT_PTR -> "intptr"
; pszMore : LPCWSTR optional -> "wstr"
; dwFlags : PATHCCH_OPTIONS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。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")
	procPathCchAppendEx = api_ms_win_core_path_l1_1_0.NewProc("PathCchAppendEx")
)

// pszPath (LPWSTR in/out), cchPath (UINT_PTR), pszMore (LPCWSTR optional), dwFlags (PATHCCH_OPTIONS)
r1, _, err := procPathCchAppendEx.Call(
	uintptr(pszPath),
	uintptr(cchPath),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszMore))),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function PathCchAppendEx(
  pszPath: PWideChar;   // LPWSTR in/out
  cchPath: NativeUInt;   // UINT_PTR
  pszMore: PWideChar;   // LPCWSTR optional
  dwFlags: DWORD   // PATHCCH_OPTIONS
): Integer; stdcall;
  external 'api-ms-win-core-path-l1-1-0.dll' name 'PathCchAppendEx';
result := DllCall("api-ms-win-core-path-l1-1-0\PathCchAppendEx"
    , "Ptr", pszPath   ; LPWSTR in/out
    , "UPtr", cchPath   ; UINT_PTR
    , "WStr", pszMore   ; LPCWSTR optional
    , "UInt", dwFlags   ; PATHCCH_OPTIONS
    , "Int")   ; return: HRESULT
●PathCchAppendEx(pszPath, cchPath, pszMore, dwFlags) = DLL("api-ms-win-core-path-l1-1-0.dll", "int PathCchAppendEx(char*, int, char*, dword)")
# 呼び出し: PathCchAppendEx(pszPath, cchPath, pszMore, dwFlags)
# pszPath : LPWSTR in/out -> "char*"
# cchPath : UINT_PTR -> "int"
# pszMore : LPCWSTR optional -> "char*"
# dwFlags : PATHCCH_OPTIONS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。