Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › HWPROFILEINFO_W

HWPROFILEINFO_W

構造体
サイズx64: 168 バイト / x86: 168 バイトパッキング1

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
HWPI_ulHWProfileDWORD4+0+0ハードウェアプロファイルの識別番号(ハンドル)。
HWPI_szFriendlyNameWCHAR160+4+4ハードウェアプロファイルの表示名(Unicode)。固定長バッファ。
HWPI_dwFlagsDWORD4+164+164プロファイルの状態を示すフラグ群(現在/有効等)。

各言語での定義

#include <windows.h>

// HWPROFILEINFO_W  (x64 168 / x86 168 バイト)
#pragma pack(push, 1)
typedef struct HWPROFILEINFO_W {
    DWORD HWPI_ulHWProfile;
    WCHAR HWPI_szFriendlyName[80];
    DWORD HWPI_dwFlags;
} HWPROFILEINFO_W;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct HWPROFILEINFO_W
{
    public uint HWPI_ulHWProfile;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] public string HWPI_szFriendlyName;
    public uint HWPI_dwFlags;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure HWPROFILEINFO_W
    Public HWPI_ulHWProfile As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public HWPI_szFriendlyName As String
    Public HWPI_dwFlags As UInteger
End Structure
import ctypes
from ctypes import wintypes

class HWPROFILEINFO_W(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("HWPI_ulHWProfile", wintypes.DWORD),
        ("HWPI_szFriendlyName", ctypes.c_wchar * 80),
        ("HWPI_dwFlags", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct HWPROFILEINFO_W {
    pub HWPI_ulHWProfile: u32,
    pub HWPI_szFriendlyName: [u16; 80],
    pub HWPI_dwFlags: u32,
}
import "golang.org/x/sys/windows"

type HWPROFILEINFO_W struct {
	HWPI_ulHWProfile uint32
	HWPI_szFriendlyName [80]uint16
	HWPI_dwFlags uint32
}
type
  HWPROFILEINFO_W = packed record
    HWPI_ulHWProfile: DWORD;
    HWPI_szFriendlyName: array[0..79] of WideChar;
    HWPI_dwFlags: DWORD;
  end;
const HWPROFILEINFO_W = extern struct {
    HWPI_ulHWProfile: u32,
    HWPI_szFriendlyName: [80]u16,
    HWPI_dwFlags: u32,
};
type
  HWPROFILEINFO_W {.packed.} = object
    HWPI_ulHWProfile: uint32
    HWPI_szFriendlyName: array[80, uint16]
    HWPI_dwFlags: uint32
align(1)
struct HWPROFILEINFO_W
{
    uint HWPI_ulHWProfile;
    wchar[80] HWPI_szFriendlyName;
    uint HWPI_dwFlags;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; HWPROFILEINFO_W サイズ: 168 バイト(x64)
dim st, 42    ; 4byte整数×42(構造体サイズ 168 / 4 切り上げ)
; HWPI_ulHWProfile : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; HWPI_szFriendlyName : WCHAR (+4, 160byte)  varptr(st)+4 を基点に操作(160byte:入れ子/配列)
; HWPI_dwFlags : DWORD (+164, 4byte)  st.41 = 値  /  値 = st.41   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global HWPROFILEINFO_W, pack=1
    #field int HWPI_ulHWProfile
    #field wchar HWPI_szFriendlyName 80
    #field int HWPI_dwFlags
#endstruct

stdim st, HWPROFILEINFO_W        ; NSTRUCT 変数を確保
st->HWPI_ulHWProfile = 100
mes "HWPI_ulHWProfile=" + st->HWPI_ulHWProfile