StrDupW
関数文字列を複製して新しいバッファに格納する。
シグネチャ
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
LPWSTR StrDupW(
LPCWSTR pszSrch
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszSrch | LPCWSTR | in |
戻り値の型: LPWSTR
各言語での呼び出し定義
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
LPWSTR StrDupW(
LPCWSTR pszSrch
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr StrDupW(
[MarshalAs(UnmanagedType.LPWStr)] string pszSrch // LPCWSTR
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function StrDupW(
<MarshalAs(UnmanagedType.LPWStr)> pszSrch As String ' LPCWSTR
) As IntPtr
End Function' pszSrch : LPCWSTR
Declare PtrSafe Function StrDupW Lib "shlwapi" ( _
ByVal pszSrch As LongPtr) As LongPtr
' 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
StrDupW = ctypes.windll.shlwapi.StrDupW
StrDupW.restype = wintypes.LPWSTR
StrDupW.argtypes = [
wintypes.LPCWSTR, # pszSrch : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
StrDupW = Fiddle::Function.new(
lib['StrDupW'],
[
Fiddle::TYPE_VOIDP, # pszSrch : LPCWSTR
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shlwapi")]
extern "system" {
fn StrDupW(
pszSrch: *const u16 // LPCWSTR
) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr StrDupW([MarshalAs(UnmanagedType.LPWStr)] string pszSrch);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_StrDupW' -Namespace Win32 -PassThru
# $api::StrDupW(pszSrch)#uselib "SHLWAPI.dll"
#func global StrDupW "StrDupW" wptr
; StrDupW pszSrch ; 戻り値は stat
; pszSrch : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global StrDupW "StrDupW" wstr
; res = StrDupW(pszSrch)
; pszSrch : LPCWSTR -> "wstr"; LPWSTR StrDupW(LPCWSTR pszSrch)
#uselib "SHLWAPI.dll"
#cfunc global StrDupW "StrDupW" wstr
; res = StrDupW(pszSrch)
; pszSrch : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procStrDupW = shlwapi.NewProc("StrDupW")
)
// pszSrch (LPCWSTR)
r1, _, err := procStrDupW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSrch))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPWSTRfunction StrDupW(
pszSrch: PWideChar // LPCWSTR
): PWideChar; stdcall;
external 'SHLWAPI.dll' name 'StrDupW';result := DllCall("SHLWAPI\StrDupW"
, "WStr", pszSrch ; LPCWSTR
, "Ptr") ; return: LPWSTR●StrDupW(pszSrch) = DLL("SHLWAPI.dll", "char* StrDupW(char*)")
# 呼び出し: StrDupW(pszSrch)
# pszSrch : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。