ホーム › System.WindowsProgramming › RtlCharToInteger
RtlCharToInteger
関数文字列を指定基数で整数値に変換する。
シグネチャ
// ntdll.dll
#include <windows.h>
NTSTATUS RtlCharToInteger(
CHAR* String,
DWORD Base,
DWORD* Value
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| String | CHAR* | inout |
| Base | DWORD | in |
| Value | DWORD* | inout |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// ntdll.dll
#include <windows.h>
NTSTATUS RtlCharToInteger(
CHAR* String,
DWORD Base,
DWORD* Value
);[DllImport("ntdll.dll", ExactSpelling = true)]
static extern int RtlCharToInteger(
IntPtr String, // CHAR* in/out
uint Base, // DWORD
ref uint Value // DWORD* in/out
);<DllImport("ntdll.dll", ExactSpelling:=True)>
Public Shared Function RtlCharToInteger(
[String] As IntPtr, ' CHAR* in/out
Base As UInteger, ' DWORD
ByRef Value As UInteger ' DWORD* in/out
) As Integer
End Function' String : CHAR* in/out
' Base : DWORD
' Value : DWORD* in/out
Declare PtrSafe Function RtlCharToInteger Lib "ntdll" ( _
ByVal String As LongPtr, _
ByVal Base As Long, _
ByRef Value As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RtlCharToInteger = ctypes.windll.ntdll.RtlCharToInteger
RtlCharToInteger.restype = ctypes.c_int
RtlCharToInteger.argtypes = [
ctypes.POINTER(ctypes.c_byte), # String : CHAR* in/out
wintypes.DWORD, # Base : DWORD
ctypes.POINTER(wintypes.DWORD), # Value : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ntdll.dll')
RtlCharToInteger = Fiddle::Function.new(
lib['RtlCharToInteger'],
[
Fiddle::TYPE_VOIDP, # String : CHAR* in/out
-Fiddle::TYPE_INT, # Base : DWORD
Fiddle::TYPE_VOIDP, # Value : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "ntdll")]
extern "system" {
fn RtlCharToInteger(
String: *mut i8, // CHAR* in/out
Base: u32, // DWORD
Value: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ntdll.dll")]
public static extern int RtlCharToInteger(IntPtr String, uint Base, ref uint Value);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ntdll_RtlCharToInteger' -Namespace Win32 -PassThru
# $api::RtlCharToInteger(String, Base, Value)#uselib "ntdll.dll"
#func global RtlCharToInteger "RtlCharToInteger" sptr, sptr, sptr
; RtlCharToInteger varptr(String), Base, varptr(Value) ; 戻り値は stat
; String : CHAR* in/out -> "sptr"
; Base : DWORD -> "sptr"
; Value : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ntdll.dll" #cfunc global RtlCharToInteger "RtlCharToInteger" var, int, var ; res = RtlCharToInteger(String, Base, Value) ; String : CHAR* in/out -> "var" ; Base : DWORD -> "int" ; Value : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ntdll.dll" #cfunc global RtlCharToInteger "RtlCharToInteger" sptr, int, sptr ; res = RtlCharToInteger(varptr(String), Base, varptr(Value)) ; String : CHAR* in/out -> "sptr" ; Base : DWORD -> "int" ; Value : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS RtlCharToInteger(CHAR* String, DWORD Base, DWORD* Value) #uselib "ntdll.dll" #cfunc global RtlCharToInteger "RtlCharToInteger" var, int, var ; res = RtlCharToInteger(String, Base, Value) ; String : CHAR* in/out -> "var" ; Base : DWORD -> "int" ; Value : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS RtlCharToInteger(CHAR* String, DWORD Base, DWORD* Value) #uselib "ntdll.dll" #cfunc global RtlCharToInteger "RtlCharToInteger" intptr, int, intptr ; res = RtlCharToInteger(varptr(String), Base, varptr(Value)) ; String : CHAR* in/out -> "intptr" ; Base : DWORD -> "int" ; Value : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ntdll = windows.NewLazySystemDLL("ntdll.dll")
procRtlCharToInteger = ntdll.NewProc("RtlCharToInteger")
)
// String (CHAR* in/out), Base (DWORD), Value (DWORD* in/out)
r1, _, err := procRtlCharToInteger.Call(
uintptr(String),
uintptr(Base),
uintptr(Value),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction RtlCharToInteger(
String: Pointer; // CHAR* in/out
Base: DWORD; // DWORD
Value: Pointer // DWORD* in/out
): Integer; stdcall;
external 'ntdll.dll' name 'RtlCharToInteger';result := DllCall("ntdll\RtlCharToInteger"
, "Ptr", String ; CHAR* in/out
, "UInt", Base ; DWORD
, "Ptr", Value ; DWORD* in/out
, "Int") ; return: NTSTATUS●RtlCharToInteger(String, Base, Value) = DLL("ntdll.dll", "int RtlCharToInteger(void*, dword, void*)")
# 呼び出し: RtlCharToInteger(String, Base, Value)
# String : CHAR* in/out -> "void*"
# Base : DWORD -> "dword"
# Value : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。