StrCatW
関数二つの文字列を連結する。
シグネチャ
// SHLWAPI.dll
#include <windows.h>
LPWSTR StrCatW(
LPWSTR psz1,
LPCWSTR psz2
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| psz1 | LPWSTR | inout |
| psz2 | LPCWSTR | in |
戻り値の型: LPWSTR
各言語での呼び出し定義
// SHLWAPI.dll
#include <windows.h>
LPWSTR StrCatW(
LPWSTR psz1,
LPCWSTR psz2
);[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern IntPtr StrCatW(
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder psz1, // LPWSTR in/out
[MarshalAs(UnmanagedType.LPWStr)] string psz2 // LPCWSTR
);<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function StrCatW(
<MarshalAs(UnmanagedType.LPWStr)> psz1 As System.Text.StringBuilder, ' LPWSTR in/out
<MarshalAs(UnmanagedType.LPWStr)> psz2 As String ' LPCWSTR
) As IntPtr
End Function' psz1 : LPWSTR in/out
' psz2 : LPCWSTR
Declare PtrSafe Function StrCatW Lib "shlwapi" ( _
ByVal psz1 As LongPtr, _
ByVal psz2 As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
StrCatW = ctypes.windll.shlwapi.StrCatW
StrCatW.restype = wintypes.LPWSTR
StrCatW.argtypes = [
wintypes.LPWSTR, # psz1 : LPWSTR in/out
wintypes.LPCWSTR, # psz2 : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
StrCatW = Fiddle::Function.new(
lib['StrCatW'],
[
Fiddle::TYPE_VOIDP, # psz1 : LPWSTR in/out
Fiddle::TYPE_VOIDP, # psz2 : LPCWSTR
],
Fiddle::TYPE_VOIDP)#[link(name = "shlwapi")]
extern "system" {
fn StrCatW(
psz1: *mut u16, // LPWSTR in/out
psz2: *const u16 // LPCWSTR
) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll")]
public static extern IntPtr StrCatW([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder psz1, [MarshalAs(UnmanagedType.LPWStr)] string psz2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_StrCatW' -Namespace Win32 -PassThru
# $api::StrCatW(psz1, psz2)#uselib "SHLWAPI.dll"
#func global StrCatW "StrCatW" sptr, sptr
; StrCatW varptr(psz1), psz2 ; 戻り値は stat
; psz1 : LPWSTR in/out -> "sptr"
; psz2 : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHLWAPI.dll" #cfunc global StrCatW "StrCatW" var, wstr ; res = StrCatW(psz1, psz2) ; psz1 : LPWSTR in/out -> "var" ; psz2 : LPCWSTR -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHLWAPI.dll" #cfunc global StrCatW "StrCatW" sptr, wstr ; res = StrCatW(varptr(psz1), psz2) ; psz1 : LPWSTR in/out -> "sptr" ; psz2 : LPCWSTR -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; LPWSTR StrCatW(LPWSTR psz1, LPCWSTR psz2) #uselib "SHLWAPI.dll" #cfunc global StrCatW "StrCatW" var, wstr ; res = StrCatW(psz1, psz2) ; psz1 : LPWSTR in/out -> "var" ; psz2 : LPCWSTR -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; LPWSTR StrCatW(LPWSTR psz1, LPCWSTR psz2) #uselib "SHLWAPI.dll" #cfunc global StrCatW "StrCatW" intptr, wstr ; res = StrCatW(varptr(psz1), psz2) ; psz1 : LPWSTR in/out -> "intptr" ; psz2 : LPCWSTR -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procStrCatW = shlwapi.NewProc("StrCatW")
)
// psz1 (LPWSTR in/out), psz2 (LPCWSTR)
r1, _, err := procStrCatW.Call(
uintptr(psz1),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(psz2))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPWSTRfunction StrCatW(
psz1: PWideChar; // LPWSTR in/out
psz2: PWideChar // LPCWSTR
): PWideChar; stdcall;
external 'SHLWAPI.dll' name 'StrCatW';result := DllCall("SHLWAPI\StrCatW"
, "Ptr", psz1 ; LPWSTR in/out
, "WStr", psz2 ; LPCWSTR
, "Ptr") ; return: LPWSTR●StrCatW(psz1, psz2) = DLL("SHLWAPI.dll", "char* StrCatW(char*, char*)")
# 呼び出し: StrCatW(psz1, psz2)
# psz1 : LPWSTR in/out -> "char*"
# psz2 : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。