PathCchAppend
関数既存パスの末尾に別のパス要素を追加する。
シグネチャ
// api-ms-win-core-path-l1-1-0.dll
#include <windows.h>
HRESULT PathCchAppend(
LPWSTR pszPath,
UINT_PTR cchPath,
LPCWSTR pszMore // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszPath | LPWSTR | inout |
| cchPath | UINT_PTR | in |
| pszMore | LPCWSTR | inoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// api-ms-win-core-path-l1-1-0.dll
#include <windows.h>
HRESULT PathCchAppend(
LPWSTR pszPath,
UINT_PTR cchPath,
LPCWSTR pszMore // optional
);[DllImport("api-ms-win-core-path-l1-1-0.dll", ExactSpelling = true)]
static extern int PathCchAppend(
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszPath, // LPWSTR in/out
UIntPtr cchPath, // UINT_PTR
[MarshalAs(UnmanagedType.LPWStr)] string pszMore // LPCWSTR optional
);<DllImport("api-ms-win-core-path-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function PathCchAppend(
<MarshalAs(UnmanagedType.LPWStr)> pszPath As System.Text.StringBuilder, ' LPWSTR in/out
cchPath As UIntPtr, ' UINT_PTR
<MarshalAs(UnmanagedType.LPWStr)> pszMore As String ' LPCWSTR optional
) As Integer
End Function' pszPath : LPWSTR in/out
' cchPath : UINT_PTR
' pszMore : LPCWSTR optional
Declare PtrSafe Function PathCchAppend Lib "api-ms-win-core-path-l1-1-0" ( _
ByVal pszPath As LongPtr, _
ByVal cchPath As LongPtr, _
ByVal pszMore As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PathCchAppend = ctypes.windll.LoadLibrary("api-ms-win-core-path-l1-1-0.dll").PathCchAppend
PathCchAppend.restype = ctypes.c_int
PathCchAppend.argtypes = [
wintypes.LPWSTR, # pszPath : LPWSTR in/out
ctypes.c_size_t, # cchPath : UINT_PTR
wintypes.LPCWSTR, # pszMore : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-path-l1-1-0.dll')
PathCchAppend = Fiddle::Function.new(
lib['PathCchAppend'],
[
Fiddle::TYPE_VOIDP, # pszPath : LPWSTR in/out
Fiddle::TYPE_UINTPTR_T, # cchPath : UINT_PTR
Fiddle::TYPE_VOIDP, # pszMore : LPCWSTR optional
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-path-l1-1-0")]
extern "system" {
fn PathCchAppend(
pszPath: *mut u16, // LPWSTR in/out
cchPath: usize, // UINT_PTR
pszMore: *const u16 // LPCWSTR optional
) -> 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 PathCchAppend([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszPath, UIntPtr cchPath, [MarshalAs(UnmanagedType.LPWStr)] string pszMore);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-path-l1-1-0_PathCchAppend' -Namespace Win32 -PassThru
# $api::PathCchAppend(pszPath, cchPath, pszMore)#uselib "api-ms-win-core-path-l1-1-0.dll"
#func global PathCchAppend "PathCchAppend" sptr, sptr, sptr
; PathCchAppend varptr(pszPath), cchPath, pszMore ; 戻り値は stat
; pszPath : LPWSTR in/out -> "sptr"
; cchPath : UINT_PTR -> "sptr"
; pszMore : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-path-l1-1-0.dll" #cfunc global PathCchAppend "PathCchAppend" var, sptr, wstr ; res = PathCchAppend(pszPath, cchPath, pszMore) ; pszPath : LPWSTR in/out -> "var" ; cchPath : UINT_PTR -> "sptr" ; pszMore : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-core-path-l1-1-0.dll" #cfunc global PathCchAppend "PathCchAppend" sptr, sptr, wstr ; res = PathCchAppend(varptr(pszPath), cchPath, pszMore) ; pszPath : LPWSTR in/out -> "sptr" ; cchPath : UINT_PTR -> "sptr" ; pszMore : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT PathCchAppend(LPWSTR pszPath, UINT_PTR cchPath, LPCWSTR pszMore) #uselib "api-ms-win-core-path-l1-1-0.dll" #cfunc global PathCchAppend "PathCchAppend" var, intptr, wstr ; res = PathCchAppend(pszPath, cchPath, pszMore) ; pszPath : LPWSTR in/out -> "var" ; cchPath : UINT_PTR -> "intptr" ; pszMore : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT PathCchAppend(LPWSTR pszPath, UINT_PTR cchPath, LPCWSTR pszMore) #uselib "api-ms-win-core-path-l1-1-0.dll" #cfunc global PathCchAppend "PathCchAppend" intptr, intptr, wstr ; res = PathCchAppend(varptr(pszPath), cchPath, pszMore) ; pszPath : LPWSTR in/out -> "intptr" ; cchPath : UINT_PTR -> "intptr" ; pszMore : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数はポインタ方式(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")
procPathCchAppend = api_ms_win_core_path_l1_1_0.NewProc("PathCchAppend")
)
// pszPath (LPWSTR in/out), cchPath (UINT_PTR), pszMore (LPCWSTR optional)
r1, _, err := procPathCchAppend.Call(
uintptr(pszPath),
uintptr(cchPath),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszMore))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction PathCchAppend(
pszPath: PWideChar; // LPWSTR in/out
cchPath: NativeUInt; // UINT_PTR
pszMore: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'api-ms-win-core-path-l1-1-0.dll' name 'PathCchAppend';result := DllCall("api-ms-win-core-path-l1-1-0\PathCchAppend"
, "Ptr", pszPath ; LPWSTR in/out
, "UPtr", cchPath ; UINT_PTR
, "WStr", pszMore ; LPCWSTR optional
, "Int") ; return: HRESULT●PathCchAppend(pszPath, cchPath, pszMore) = DLL("api-ms-win-core-path-l1-1-0.dll", "int PathCchAppend(char*, int, char*)")
# 呼び出し: PathCchAppend(pszPath, cchPath, pszMore)
# pszPath : LPWSTR in/out -> "char*"
# cchPath : UINT_PTR -> "int"
# pszMore : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。