Win32 API 日本語リファレンス
ホームSystem.WindowsProgramming › RtlInitString

RtlInitString

関数
カウント付き文字列構造体を初期化する。
DLLntdll.dll呼出規約winapi

シグネチャ

// ntdll.dll
#include <windows.h>

void RtlInitString(
    STRING* DestinationString,
    CHAR* SourceString
);

パラメーター

名前方向
DestinationStringSTRING*inout
SourceStringCHAR*inout

戻り値の型: void

各言語での呼び出し定義

// ntdll.dll
#include <windows.h>

void RtlInitString(
    STRING* DestinationString,
    CHAR* SourceString
);
[DllImport("ntdll.dll", ExactSpelling = true)]
static extern void RtlInitString(
    IntPtr DestinationString,   // STRING* in/out
    IntPtr SourceString   // CHAR* in/out
);
<DllImport("ntdll.dll", ExactSpelling:=True)>
Public Shared Sub RtlInitString(
    DestinationString As IntPtr,   ' STRING* in/out
    SourceString As IntPtr   ' CHAR* in/out
)
End Sub
' DestinationString : STRING* in/out
' SourceString : CHAR* in/out
Declare PtrSafe Sub RtlInitString Lib "ntdll" ( _
    ByVal DestinationString As LongPtr, _
    ByVal SourceString As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtlInitString = ctypes.windll.ntdll.RtlInitString
RtlInitString.restype = None
RtlInitString.argtypes = [
    ctypes.c_void_p,  # DestinationString : STRING* in/out
    ctypes.POINTER(ctypes.c_byte),  # SourceString : CHAR* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ntdll.dll')
RtlInitString = Fiddle::Function.new(
  lib['RtlInitString'],
  [
    Fiddle::TYPE_VOIDP,  # DestinationString : STRING* in/out
    Fiddle::TYPE_VOIDP,  # SourceString : CHAR* in/out
  ],
  Fiddle::TYPE_VOID)
#[link(name = "ntdll")]
extern "system" {
    fn RtlInitString(
        DestinationString: *mut STRING,  // STRING* in/out
        SourceString: *mut i8  // CHAR* in/out
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ntdll.dll")]
public static extern void RtlInitString(IntPtr DestinationString, IntPtr SourceString);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ntdll_RtlInitString' -Namespace Win32 -PassThru
# $api::RtlInitString(DestinationString, SourceString)
#uselib "ntdll.dll"
#func global RtlInitString "RtlInitString" sptr, sptr
; RtlInitString varptr(DestinationString), varptr(SourceString)
; DestinationString : STRING* in/out -> "sptr"
; SourceString : CHAR* in/out -> "sptr"
出力引数:
#uselib "ntdll.dll"
#func global RtlInitString "RtlInitString" var, var
; RtlInitString DestinationString, SourceString
; DestinationString : STRING* in/out -> "var"
; SourceString : CHAR* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void RtlInitString(STRING* DestinationString, CHAR* SourceString)
#uselib "ntdll.dll"
#func global RtlInitString "RtlInitString" var, var
; RtlInitString DestinationString, SourceString
; DestinationString : STRING* in/out -> "var"
; SourceString : CHAR* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdll = windows.NewLazySystemDLL("ntdll.dll")
	procRtlInitString = ntdll.NewProc("RtlInitString")
)

// DestinationString (STRING* in/out), SourceString (CHAR* in/out)
r1, _, err := procRtlInitString.Call(
	uintptr(DestinationString),
	uintptr(SourceString),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure RtlInitString(
  DestinationString: Pointer;   // STRING* in/out
  SourceString: Pointer   // CHAR* in/out
); stdcall;
  external 'ntdll.dll' name 'RtlInitString';
result := DllCall("ntdll\RtlInitString"
    , "Ptr", DestinationString   ; STRING* in/out
    , "Ptr", SourceString   ; CHAR* in/out
    , "Int")   ; return: void
●RtlInitString(DestinationString, SourceString) = DLL("ntdll.dll", "int RtlInitString(void*, void*)")
# 呼び出し: RtlInitString(DestinationString, SourceString)
# DestinationString : STRING* in/out -> "void*"
# SourceString : CHAR* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。