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

SP_REGISTER_CONTROL_STATUSA

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

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

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のバイト単位サイズ。呼び出し前に設定する。
FileNameLPSTR8/4+4+4登録/登録解除対象のCOMサーバ等ファイル名(ANSI)。
Win32ErrorDWORD4+12+8登録処理の結果を示すWin32エラーコード。成功時は0。
FailureCodeDWORD4+16+12登録失敗の段階を示すコード(SPREG_*)。失敗箇所を特定する。

各言語での定義

#include <windows.h>

// SP_REGISTER_CONTROL_STATUSA  (x64 20 / x86 16 バイト)
#pragma pack(push, 1)
typedef struct SP_REGISTER_CONTROL_STATUSA {
    DWORD cbSize;
    LPSTR FileName;
    DWORD Win32Error;
    DWORD FailureCode;
} SP_REGISTER_CONTROL_STATUSA;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SP_REGISTER_CONTROL_STATUSA
{
    public uint cbSize;
    public IntPtr FileName;
    public uint Win32Error;
    public uint FailureCode;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure SP_REGISTER_CONTROL_STATUSA
    Public cbSize As UInteger
    Public FileName As IntPtr
    Public Win32Error As UInteger
    Public FailureCode As UInteger
End Structure
import ctypes
from ctypes import wintypes

class SP_REGISTER_CONTROL_STATUSA(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("FileName", ctypes.c_void_p),
        ("Win32Error", wintypes.DWORD),
        ("FailureCode", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct SP_REGISTER_CONTROL_STATUSA {
    pub cbSize: u32,
    pub FileName: *mut core::ffi::c_void,
    pub Win32Error: u32,
    pub FailureCode: u32,
}
import "golang.org/x/sys/windows"

type SP_REGISTER_CONTROL_STATUSA struct {
	cbSize uint32
	FileName uintptr
	Win32Error uint32
	FailureCode uint32
}
type
  SP_REGISTER_CONTROL_STATUSA = packed record
    cbSize: DWORD;
    FileName: Pointer;
    Win32Error: DWORD;
    FailureCode: DWORD;
  end;
const SP_REGISTER_CONTROL_STATUSA = extern struct {
    cbSize: u32,
    FileName: ?*anyopaque,
    Win32Error: u32,
    FailureCode: u32,
};
type
  SP_REGISTER_CONTROL_STATUSA {.packed.} = object
    cbSize: uint32
    FileName: pointer
    Win32Error: uint32
    FailureCode: uint32
align(1)
struct SP_REGISTER_CONTROL_STATUSA
{
    uint cbSize;
    void* FileName;
    uint Win32Error;
    uint FailureCode;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SP_REGISTER_CONTROL_STATUSA サイズ: 16 バイト(x86)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; FileName : LPSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Win32Error : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; FailureCode : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SP_REGISTER_CONTROL_STATUSA サイズ: 20 バイト(x64)
dim st, 5    ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; FileName : LPSTR (+4, 8byte)  qpoke st,4,値 / qpeek(st,4)  ※IronHSPのみ。3.7/3.8は lpoke st,4,下位 : lpoke st,8,上位
; Win32Error : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; FailureCode : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SP_REGISTER_CONTROL_STATUSA, pack=1
    #field int cbSize
    #field intptr FileName
    #field int Win32Error
    #field int FailureCode
#endstruct

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