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

公式ドキュメント

デバイスファミリー情報の文字列表現を取得します。

戻り値

型: DWORD

成功または失敗を示すステータスです。

解説(Remarks)

現時点では、この関数に関連付けられたライブラリファイルはありません。アプリケーションは、DLL名(NtDll.dll)を指定して LoadLibrary を呼び出すことでモジュールハンドルを取得できます。続いて、そのモジュールハンドルとこの関数名を指定して GetProcAddress を呼び出すことで、関数のアドレスを取得できます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// 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)。
const std = @import("std");

extern "ntdll" fn RtlConvertDeviceFamilyInfoToString(
    pulDeviceFamilyBufferSize: [*c]u32, // DWORD* in/out
    pulDeviceFormBufferSize: [*c]u32, // DWORD* in/out
    DeviceFamily: [*c]u16, // LPWSTR out
    DeviceForm: [*c]u16 // LPWSTR out
) callconv(std.os.windows.WINAPI) u32;
proc RtlConvertDeviceFamilyInfoToString(
    pulDeviceFamilyBufferSize: ptr uint32,  # DWORD* in/out
    pulDeviceFormBufferSize: ptr uint32,  # DWORD* in/out
    DeviceFamily: ptr uint16,  # LPWSTR out
    DeviceForm: ptr uint16  # LPWSTR out
): uint32 {.importc: "RtlConvertDeviceFamilyInfoToString", stdcall, dynlib: "ntdll.dll".}
pragma(lib, "ntdll");
extern(Windows)
uint RtlConvertDeviceFamilyInfoToString(
    uint* pulDeviceFamilyBufferSize,   // DWORD* in/out
    uint* pulDeviceFormBufferSize,   // DWORD* in/out
    wchar* DeviceFamily,   // LPWSTR out
    wchar* DeviceForm   // LPWSTR out
);
ccall((:RtlConvertDeviceFamilyInfoToString, "ntdll.dll"), stdcall, UInt32,
      (Ptr{UInt32}, Ptr{UInt32}, Ptr{UInt16}, Ptr{UInt16}),
      pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm)
# pulDeviceFamilyBufferSize : DWORD* in/out -> Ptr{UInt32}
# pulDeviceFormBufferSize : DWORD* in/out -> Ptr{UInt32}
# DeviceFamily : LPWSTR out -> Ptr{UInt16}
# DeviceForm : LPWSTR out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t RtlConvertDeviceFamilyInfoToString(
    uint32_t* pulDeviceFamilyBufferSize,
    uint32_t* pulDeviceFormBufferSize,
    uint16_t* DeviceFamily,
    uint16_t* DeviceForm);
]]
local ntdll = ffi.load("ntdll")
-- ntdll.RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm)
-- pulDeviceFamilyBufferSize : DWORD* in/out
-- pulDeviceFormBufferSize : DWORD* in/out
-- DeviceFamily : LPWSTR out
-- DeviceForm : LPWSTR out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ntdll.dll');
const RtlConvertDeviceFamilyInfoToString = lib.func('__stdcall', 'RtlConvertDeviceFamilyInfoToString', 'uint32_t', ['uint32_t *', 'uint32_t *', 'uint16_t *', 'uint16_t *']);
// RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm)
// pulDeviceFamilyBufferSize : DWORD* in/out -> 'uint32_t *'
// pulDeviceFormBufferSize : DWORD* in/out -> 'uint32_t *'
// DeviceFamily : LPWSTR out -> 'uint16_t *'
// DeviceForm : LPWSTR out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ntdll.dll", {
  RtlConvertDeviceFamilyInfoToString: { parameters: ["pointer", "pointer", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm)
// pulDeviceFamilyBufferSize : DWORD* in/out -> "pointer"
// pulDeviceFormBufferSize : DWORD* in/out -> "pointer"
// DeviceFamily : LPWSTR out -> "buffer"
// DeviceForm : LPWSTR out -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t RtlConvertDeviceFamilyInfoToString(
    uint32_t* pulDeviceFamilyBufferSize,
    uint32_t* pulDeviceFormBufferSize,
    uint16_t* DeviceFamily,
    uint16_t* DeviceForm);
C, "ntdll.dll");
// $ffi->RtlConvertDeviceFamilyInfoToString(pulDeviceFamilyBufferSize, pulDeviceFormBufferSize, DeviceFamily, DeviceForm);
// pulDeviceFamilyBufferSize : DWORD* in/out
// pulDeviceFormBufferSize : DWORD* in/out
// DeviceFamily : LPWSTR out
// DeviceForm : LPWSTR out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Ntdll extends StdCallLibrary {
    Ntdll INSTANCE = Native.load("ntdll", Ntdll.class);
    int RtlConvertDeviceFamilyInfoToString(
        IntByReference pulDeviceFamilyBufferSize,   // DWORD* in/out
        IntByReference pulDeviceFormBufferSize,   // DWORD* in/out
        char[] DeviceFamily,   // LPWSTR out
        char[] DeviceForm   // LPWSTR out
    );
}
@[Link("ntdll")]
lib Libntdll
  fun RtlConvertDeviceFamilyInfoToString = RtlConvertDeviceFamilyInfoToString(
    pulDeviceFamilyBufferSize : UInt32*,   # DWORD* in/out
    pulDeviceFormBufferSize : UInt32*,   # DWORD* in/out
    DeviceFamily : UInt16*,   # LPWSTR out
    DeviceForm : UInt16*   # LPWSTR out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RtlConvertDeviceFamilyInfoToStringNative = Uint32 Function(Pointer<Uint32>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Utf16>);
typedef RtlConvertDeviceFamilyInfoToStringDart = int Function(Pointer<Uint32>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Utf16>);
final RtlConvertDeviceFamilyInfoToString = DynamicLibrary.open('ntdll.dll')
    .lookupFunction<RtlConvertDeviceFamilyInfoToStringNative, RtlConvertDeviceFamilyInfoToStringDart>('RtlConvertDeviceFamilyInfoToString');
// pulDeviceFamilyBufferSize : DWORD* in/out -> Pointer<Uint32>
// pulDeviceFormBufferSize : DWORD* in/out -> Pointer<Uint32>
// DeviceFamily : LPWSTR out -> Pointer<Utf16>
// DeviceForm : LPWSTR out -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RtlConvertDeviceFamilyInfoToString"
  c_RtlConvertDeviceFamilyInfoToString :: Ptr Word32 -> Ptr Word32 -> CWString -> CWString -> IO Word32
-- pulDeviceFamilyBufferSize : DWORD* in/out -> Ptr Word32
-- pulDeviceFormBufferSize : DWORD* in/out -> Ptr Word32
-- DeviceFamily : LPWSTR out -> CWString
-- DeviceForm : LPWSTR out -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rtlconvertdevicefamilyinfotostring =
  foreign "RtlConvertDeviceFamilyInfoToString"
    ((ptr uint32_t) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* pulDeviceFamilyBufferSize : DWORD* in/out -> (ptr uint32_t) *)
(* pulDeviceFormBufferSize : DWORD* in/out -> (ptr uint32_t) *)
(* DeviceFamily : LPWSTR out -> (ptr uint16_t) *)
(* DeviceForm : LPWSTR out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ntdll (t "ntdll.dll"))
(cffi:use-foreign-library ntdll)

(cffi:defcfun ("RtlConvertDeviceFamilyInfoToString" rtl-convert-device-family-info-to-string :convention :stdcall) :uint32
  (pul-device-family-buffer-size :pointer)   ; DWORD* in/out
  (pul-device-form-buffer-size :pointer)   ; DWORD* in/out
  (device-family :pointer)   ; LPWSTR out
  (device-form :pointer))   ; LPWSTR out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RtlConvertDeviceFamilyInfoToString = Win32::API::More->new('ntdll',
    'DWORD RtlConvertDeviceFamilyInfoToString(LPVOID pulDeviceFamilyBufferSize, LPVOID pulDeviceFormBufferSize, LPWSTR DeviceFamily, LPWSTR DeviceForm)');
# my $ret = $RtlConvertDeviceFamilyInfoToString->Call($pulDeviceFamilyBufferSize, $pulDeviceFormBufferSize, $DeviceFamily, $DeviceForm);
# pulDeviceFamilyBufferSize : DWORD* in/out -> LPVOID
# pulDeviceFormBufferSize : DWORD* in/out -> LPVOID
# DeviceFamily : LPWSTR out -> LPWSTR
# DeviceForm : LPWSTR out -> LPWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。