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