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

RtlConvertDeviceFamilyInfoToString

関数
デバイスファミリと外形種別を文字列に変換する。
DLLntdll.dll呼出規約winapi

シグネチャ

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

DWORD RtlConvertDeviceFamilyInfoToString(
    DWORD* pulDeviceFamilyBufferSize,
    DWORD* pulDeviceFormBufferSize,
    LPWSTR DeviceFamily,
    LPWSTR DeviceForm
);

パラメーター

名前方向
pulDeviceFamilyBufferSizeDWORD*inout
pulDeviceFormBufferSizeDWORD*inout
DeviceFamilyLPWSTRout
DeviceFormLPWSTRout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RtlConvertDeviceFamilyInfoToString(
    DWORD* pulDeviceFamilyBufferSize,
    DWORD* pulDeviceFormBufferSize,
    LPWSTR DeviceFamily,
    LPWSTR DeviceForm
);
[DllImport("ntdll.dll", ExactSpelling = true)]
static extern uint RtlConvertDeviceFamilyInfoToString(
    ref uint pulDeviceFamilyBufferSize,   // DWORD* in/out
    ref uint pulDeviceFormBufferSize,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DeviceFamily,   // LPWSTR out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DeviceForm   // LPWSTR out
);
<DllImport("ntdll.dll", ExactSpelling:=True)>
Public Shared Function RtlConvertDeviceFamilyInfoToString(
    ByRef pulDeviceFamilyBufferSize As UInteger,   ' DWORD* in/out
    ByRef pulDeviceFormBufferSize As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> DeviceFamily As System.Text.StringBuilder,   ' LPWSTR out
    <MarshalAs(UnmanagedType.LPWStr)> DeviceForm As System.Text.StringBuilder   ' LPWSTR out
) As UInteger
End Function
' pulDeviceFamilyBufferSize : DWORD* in/out
' pulDeviceFormBufferSize : DWORD* in/out
' DeviceFamily : LPWSTR out
' DeviceForm : LPWSTR out
Declare PtrSafe Function RtlConvertDeviceFamilyInfoToString Lib "ntdll" ( _
    ByRef pulDeviceFamilyBufferSize As Long, _
    ByRef pulDeviceFormBufferSize As Long, _
    ByVal DeviceFamily As LongPtr, _
    ByVal DeviceForm As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtlConvertDeviceFamilyInfoToString = ctypes.windll.ntdll.RtlConvertDeviceFamilyInfoToString
RtlConvertDeviceFamilyInfoToString.restype = wintypes.DWORD
RtlConvertDeviceFamilyInfoToString.argtypes = [
    ctypes.POINTER(wintypes.DWORD),  # pulDeviceFamilyBufferSize : DWORD* in/out
    ctypes.POINTER(wintypes.DWORD),  # pulDeviceFormBufferSize : DWORD* in/out
    wintypes.LPWSTR,  # DeviceFamily : LPWSTR out
    wintypes.LPWSTR,  # DeviceForm : LPWSTR out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ntdll.dll')
RtlConvertDeviceFamilyInfoToString = Fiddle::Function.new(
  lib['RtlConvertDeviceFamilyInfoToString'],
  [
    Fiddle::TYPE_VOIDP,  # pulDeviceFamilyBufferSize : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # pulDeviceFormBufferSize : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # DeviceFamily : LPWSTR out
    Fiddle::TYPE_VOIDP,  # DeviceForm : LPWSTR out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "ntdll")]
extern "system" {
    fn RtlConvertDeviceFamilyInfoToString(
        pulDeviceFamilyBufferSize: *mut u32,  // DWORD* in/out
        pulDeviceFormBufferSize: *mut u32,  // DWORD* in/out
        DeviceFamily: *mut u16,  // LPWSTR out
        DeviceForm: *mut u16  // LPWSTR out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ntdll.dll")]
public static extern uint RtlConvertDeviceFamilyInfoToString(ref uint pulDeviceFamilyBufferSize, ref uint pulDeviceFormBufferSize, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DeviceFamily, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DeviceForm);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ntdll_RtlConvertDeviceFamilyInfoToString' -Namespace Win32 -PassThru
# $api::RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm)
#uselib "ntdll.dll"
#func global RtlConvertDeviceFamilyInfoToString "RtlConvertDeviceFamilyInfoToString" sptr, sptr, sptr, sptr
; RtlConvertDeviceFamilyInfoToString varptr(pulDeviceFamilyBufferSize), varptr(pulDeviceFormBufferSize), varptr(DeviceFamily), varptr(DeviceForm)   ; 戻り値は stat
; pulDeviceFamilyBufferSize : DWORD* in/out -> "sptr"
; pulDeviceFormBufferSize : DWORD* in/out -> "sptr"
; DeviceFamily : LPWSTR out -> "sptr"
; DeviceForm : LPWSTR out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ntdll.dll"
#cfunc global RtlConvertDeviceFamilyInfoToString "RtlConvertDeviceFamilyInfoToString" var, var, var, var
; res = RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm)
; pulDeviceFamilyBufferSize : DWORD* in/out -> "var"
; pulDeviceFormBufferSize : DWORD* in/out -> "var"
; DeviceFamily : LPWSTR out -> "var"
; DeviceForm : LPWSTR out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD RtlConvertDeviceFamilyInfoToString(DWORD* pulDeviceFamilyBufferSize, DWORD* pulDeviceFormBufferSize, LPWSTR DeviceFamily, LPWSTR DeviceForm)
#uselib "ntdll.dll"
#cfunc global RtlConvertDeviceFamilyInfoToString "RtlConvertDeviceFamilyInfoToString" var, var, var, var
; res = RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm)
; pulDeviceFamilyBufferSize : DWORD* in/out -> "var"
; pulDeviceFormBufferSize : DWORD* in/out -> "var"
; DeviceFamily : LPWSTR out -> "var"
; DeviceForm : LPWSTR out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdll = windows.NewLazySystemDLL("ntdll.dll")
	procRtlConvertDeviceFamilyInfoToString = ntdll.NewProc("RtlConvertDeviceFamilyInfoToString")
)

// pulDeviceFamilyBufferSize (DWORD* in/out), pulDeviceFormBufferSize (DWORD* in/out), DeviceFamily (LPWSTR out), DeviceForm (LPWSTR out)
r1, _, err := procRtlConvertDeviceFamilyInfoToString.Call(
	uintptr(pulDeviceFamilyBufferSize),
	uintptr(pulDeviceFormBufferSize),
	uintptr(DeviceFamily),
	uintptr(DeviceForm),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RtlConvertDeviceFamilyInfoToString(
  pulDeviceFamilyBufferSize: Pointer;   // DWORD* in/out
  pulDeviceFormBufferSize: Pointer;   // DWORD* in/out
  DeviceFamily: PWideChar;   // LPWSTR out
  DeviceForm: PWideChar   // LPWSTR out
): DWORD; stdcall;
  external 'ntdll.dll' name 'RtlConvertDeviceFamilyInfoToString';
result := DllCall("ntdll\RtlConvertDeviceFamilyInfoToString"
    , "Ptr", pulDeviceFamilyBufferSize   ; DWORD* in/out
    , "Ptr", pulDeviceFormBufferSize   ; DWORD* in/out
    , "Ptr", DeviceFamily   ; LPWSTR out
    , "Ptr", DeviceForm   ; LPWSTR out
    , "UInt")   ; return: DWORD
●RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm) = DLL("ntdll.dll", "dword RtlConvertDeviceFamilyInfoToString(void*, void*, char*, char*)")
# 呼び出し: RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm)
# pulDeviceFamilyBufferSize : DWORD* in/out -> "void*"
# pulDeviceFormBufferSize : DWORD* in/out -> "void*"
# DeviceFamily : LPWSTR out -> "char*"
# DeviceForm : LPWSTR out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。