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

StrCatChainW

関数
指定位置にバッファ範囲内で文字列を連結する。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// SHLWAPI.dll
#include <windows.h>

DWORD StrCatChainW(
    LPWSTR pszDst,
    DWORD cchDst,
    DWORD ichAt,
    LPCWSTR pszSrc
);

パラメーター

名前方向
pszDstLPWSTRout
cchDstDWORDin
ichAtDWORDin
pszSrcLPCWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

// SHLWAPI.dll
#include <windows.h>

DWORD StrCatChainW(
    LPWSTR pszDst,
    DWORD cchDst,
    DWORD ichAt,
    LPCWSTR pszSrc
);
[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern uint StrCatChainW(
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszDst,   // LPWSTR out
    uint cchDst,   // DWORD
    uint ichAt,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pszSrc   // LPCWSTR
);
<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function StrCatChainW(
    <MarshalAs(UnmanagedType.LPWStr)> pszDst As System.Text.StringBuilder,   ' LPWSTR out
    cchDst As UInteger,   ' DWORD
    ichAt As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszSrc As String   ' LPCWSTR
) As UInteger
End Function
' pszDst : LPWSTR out
' cchDst : DWORD
' ichAt : DWORD
' pszSrc : LPCWSTR
Declare PtrSafe Function StrCatChainW Lib "shlwapi" ( _
    ByVal pszDst As LongPtr, _
    ByVal cchDst As Long, _
    ByVal ichAt As Long, _
    ByVal pszSrc As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

StrCatChainW = ctypes.windll.shlwapi.StrCatChainW
StrCatChainW.restype = wintypes.DWORD
StrCatChainW.argtypes = [
    wintypes.LPWSTR,  # pszDst : LPWSTR out
    wintypes.DWORD,  # cchDst : DWORD
    wintypes.DWORD,  # ichAt : DWORD
    wintypes.LPCWSTR,  # pszSrc : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
StrCatChainW = Fiddle::Function.new(
  lib['StrCatChainW'],
  [
    Fiddle::TYPE_VOIDP,  # pszDst : LPWSTR out
    -Fiddle::TYPE_INT,  # cchDst : DWORD
    -Fiddle::TYPE_INT,  # ichAt : DWORD
    Fiddle::TYPE_VOIDP,  # pszSrc : LPCWSTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "shlwapi")]
extern "system" {
    fn StrCatChainW(
        pszDst: *mut u16,  // LPWSTR out
        cchDst: u32,  // DWORD
        ichAt: u32,  // DWORD
        pszSrc: *const u16  // LPCWSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll")]
public static extern uint StrCatChainW([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszDst, uint cchDst, uint ichAt, [MarshalAs(UnmanagedType.LPWStr)] string pszSrc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_StrCatChainW' -Namespace Win32 -PassThru
# $api::StrCatChainW(pszDst, cchDst, ichAt, pszSrc)
#uselib "SHLWAPI.dll"
#func global StrCatChainW "StrCatChainW" sptr, sptr, sptr, sptr
; StrCatChainW varptr(pszDst), cchDst, ichAt, pszSrc   ; 戻り値は stat
; pszDst : LPWSTR out -> "sptr"
; cchDst : DWORD -> "sptr"
; ichAt : DWORD -> "sptr"
; pszSrc : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SHLWAPI.dll"
#cfunc global StrCatChainW "StrCatChainW" var, int, int, wstr
; res = StrCatChainW(pszDst, cchDst, ichAt, pszSrc)
; pszDst : LPWSTR out -> "var"
; cchDst : DWORD -> "int"
; ichAt : DWORD -> "int"
; pszSrc : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD StrCatChainW(LPWSTR pszDst, DWORD cchDst, DWORD ichAt, LPCWSTR pszSrc)
#uselib "SHLWAPI.dll"
#cfunc global StrCatChainW "StrCatChainW" var, int, int, wstr
; res = StrCatChainW(pszDst, cchDst, ichAt, pszSrc)
; pszDst : LPWSTR out -> "var"
; cchDst : DWORD -> "int"
; ichAt : DWORD -> "int"
; pszSrc : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procStrCatChainW = shlwapi.NewProc("StrCatChainW")
)

// pszDst (LPWSTR out), cchDst (DWORD), ichAt (DWORD), pszSrc (LPCWSTR)
r1, _, err := procStrCatChainW.Call(
	uintptr(pszDst),
	uintptr(cchDst),
	uintptr(ichAt),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSrc))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function StrCatChainW(
  pszDst: PWideChar;   // LPWSTR out
  cchDst: DWORD;   // DWORD
  ichAt: DWORD;   // DWORD
  pszSrc: PWideChar   // LPCWSTR
): DWORD; stdcall;
  external 'SHLWAPI.dll' name 'StrCatChainW';
result := DllCall("SHLWAPI\StrCatChainW"
    , "Ptr", pszDst   ; LPWSTR out
    , "UInt", cchDst   ; DWORD
    , "UInt", ichAt   ; DWORD
    , "WStr", pszSrc   ; LPCWSTR
    , "UInt")   ; return: DWORD
●StrCatChainW(pszDst, cchDst, ichAt, pszSrc) = DLL("SHLWAPI.dll", "dword StrCatChainW(char*, dword, dword, char*)")
# 呼び出し: StrCatChainW(pszDst, cchDst, ichAt, pszSrc)
# pszDst : LPWSTR out -> "char*"
# cchDst : DWORD -> "dword"
# ichAt : DWORD -> "dword"
# pszSrc : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。