SHChangeProductKeyAsIDList
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cb | WORD | 2 | +0 | +0 | この構造体の有効サイズをバイト単位で表す。 |
| wszProductKey | WCHAR | 78 | +2 | +2 | プロダクトキー文字列を格納する WCHAR 配列。 |
| cbZero | WORD | 2 | +80 | +80 | PIDL の終端を示すゼロ終端マーカー。常に0となる。 |
各言語での定義
#include <windows.h>
// SHChangeProductKeyAsIDList (x64 82 / x86 82 バイト)
#pragma pack(push, 1)
typedef struct SHChangeProductKeyAsIDList {
WORD cb;
WCHAR wszProductKey[39];
WORD cbZero;
} SHChangeProductKeyAsIDList;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SHChangeProductKeyAsIDList
{
public ushort cb;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 39)] public string wszProductKey;
public ushort cbZero;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure SHChangeProductKeyAsIDList
Public cb As UShort
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=39)> Public wszProductKey As String
Public cbZero As UShort
End Structureimport ctypes
from ctypes import wintypes
class SHChangeProductKeyAsIDList(ctypes.Structure):
_pack_ = 1
_fields_ = [
("cb", ctypes.c_ushort),
("wszProductKey", ctypes.c_wchar * 39),
("cbZero", ctypes.c_ushort),
]#[repr(C, packed(1))]
pub struct SHChangeProductKeyAsIDList {
pub cb: u16,
pub wszProductKey: [u16; 39],
pub cbZero: u16,
}import "golang.org/x/sys/windows"
type SHChangeProductKeyAsIDList struct {
cb uint16
wszProductKey [39]uint16
cbZero uint16
}type
SHChangeProductKeyAsIDList = packed record
cb: Word;
wszProductKey: array[0..38] of WideChar;
cbZero: Word;
end;const SHChangeProductKeyAsIDList = extern struct {
cb: u16,
wszProductKey: [39]u16,
cbZero: u16,
};type
SHChangeProductKeyAsIDList {.packed.} = object
cb: uint16
wszProductKey: array[39, uint16]
cbZero: uint16align(1)
struct SHChangeProductKeyAsIDList
{
ushort cb;
wchar[39] wszProductKey;
ushort cbZero;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SHChangeProductKeyAsIDList サイズ: 82 バイト(x64)
dim st, 21 ; 4byte整数×21(構造体サイズ 82 / 4 切り上げ)
; cb : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; wszProductKey : WCHAR (+2, 78byte) varptr(st)+2 を基点に操作(78byte:入れ子/配列)
; cbZero : WORD (+80, 2byte) wpoke st,80,値 / 値 = wpeek(st,80)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SHChangeProductKeyAsIDList, pack=1
#field short cb
#field wchar wszProductKey 39
#field short cbZero
#endstruct
stdim st, SHChangeProductKeyAsIDList ; NSTRUCT 変数を確保
st->cb = 100
mes "cb=" + st->cb