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