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

PathAppendW

関数
パスに別のパス要素を連結する。
DLLSHLWAPI.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHLWAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL PathAppendW(
    LPWSTR pszPath,
    LPCWSTR pszMore
);

パラメーター

名前方向
pszPathLPWSTRinout
pszMoreLPCWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// SHLWAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL PathAppendW(
    LPWSTR pszPath,
    LPCWSTR pszMore
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool PathAppendW(
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszPath,   // LPWSTR in/out
    [MarshalAs(UnmanagedType.LPWStr)] string pszMore   // LPCWSTR
);
<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PathAppendW(
    <MarshalAs(UnmanagedType.LPWStr)> pszPath As System.Text.StringBuilder,   ' LPWSTR in/out
    <MarshalAs(UnmanagedType.LPWStr)> pszMore As String   ' LPCWSTR
) As Boolean
End Function
' pszPath : LPWSTR in/out
' pszMore : LPCWSTR
Declare PtrSafe Function PathAppendW Lib "shlwapi" ( _
    ByVal pszPath As LongPtr, _
    ByVal pszMore As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PathAppendW = ctypes.windll.shlwapi.PathAppendW
PathAppendW.restype = wintypes.BOOL
PathAppendW.argtypes = [
    wintypes.LPWSTR,  # pszPath : LPWSTR in/out
    wintypes.LPCWSTR,  # pszMore : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
PathAppendW = Fiddle::Function.new(
  lib['PathAppendW'],
  [
    Fiddle::TYPE_VOIDP,  # pszPath : LPWSTR in/out
    Fiddle::TYPE_VOIDP,  # pszMore : LPCWSTR
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "shlwapi")]
extern "system" {
    fn PathAppendW(
        pszPath: *mut u16,  // LPWSTR in/out
        pszMore: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern bool PathAppendW([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszPath, [MarshalAs(UnmanagedType.LPWStr)] string pszMore);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_PathAppendW' -Namespace Win32 -PassThru
# $api::PathAppendW(pszPath, pszMore)
#uselib "SHLWAPI.dll"
#func global PathAppendW "PathAppendW" wptr, wptr
; PathAppendW varptr(pszPath), pszMore   ; 戻り値は stat
; pszPath : LPWSTR in/out -> "wptr"
; pszMore : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SHLWAPI.dll"
#cfunc global PathAppendW "PathAppendW" var, wstr
; res = PathAppendW(pszPath, pszMore)
; pszPath : LPWSTR in/out -> "var"
; pszMore : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL PathAppendW(LPWSTR pszPath, LPCWSTR pszMore)
#uselib "SHLWAPI.dll"
#cfunc global PathAppendW "PathAppendW" var, wstr
; res = PathAppendW(pszPath, pszMore)
; pszPath : LPWSTR in/out -> "var"
; pszMore : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procPathAppendW = shlwapi.NewProc("PathAppendW")
)

// pszPath (LPWSTR in/out), pszMore (LPCWSTR)
r1, _, err := procPathAppendW.Call(
	uintptr(pszPath),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszMore))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function PathAppendW(
  pszPath: PWideChar;   // LPWSTR in/out
  pszMore: PWideChar   // LPCWSTR
): BOOL; stdcall;
  external 'SHLWAPI.dll' name 'PathAppendW';
result := DllCall("SHLWAPI\PathAppendW"
    , "Ptr", pszPath   ; LPWSTR in/out
    , "WStr", pszMore   ; LPCWSTR
    , "Int")   ; return: BOOL
●PathAppendW(pszPath, pszMore) = DLL("SHLWAPI.dll", "bool PathAppendW(char*, char*)")
# 呼び出し: PathAppendW(pszPath, pszMore)
# pszPath : LPWSTR in/out -> "char*"
# pszMore : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。