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