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