Win32 API 日本語リファレンス
ホームSystem.Com.StructuredStorage › RemSNB

RemSNB

構造体
サイズx64: 12 バイト / x86: 12 バイト

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

フィールド

フィールドサイズx64x86説明
ulCntStrDWORD4+0+0格納される文字列の個数。SNB配列の要素数を示す。
ulCntCharDWORD4+4+4全文字列を連結した総文字数。終端含むワイド文字数。
rgStringWCHAR2+8+8連結された文字列データの先頭ワイド文字。各文字列はNULL区切りで並ぶ。

各言語での定義

#include <windows.h>

// RemSNB  (x64 12 / x86 12 バイト)
typedef struct RemSNB {
    DWORD ulCntStr;
    DWORD ulCntChar;
    WCHAR rgString[1];
} RemSNB;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RemSNB
{
    public uint ulCntStr;
    public uint ulCntChar;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] public string rgString;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RemSNB
    Public ulCntStr As UInteger
    Public ulCntChar As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)> Public rgString As String
End Structure
import ctypes
from ctypes import wintypes

class RemSNB(ctypes.Structure):
    _fields_ = [
        ("ulCntStr", wintypes.DWORD),
        ("ulCntChar", wintypes.DWORD),
        ("rgString", ctypes.c_wchar * 1),
    ]
#[repr(C)]
pub struct RemSNB {
    pub ulCntStr: u32,
    pub ulCntChar: u32,
    pub rgString: [u16; 1],
}
import "golang.org/x/sys/windows"

type RemSNB struct {
	ulCntStr uint32
	ulCntChar uint32
	rgString [1]uint16
}
type
  RemSNB = record
    ulCntStr: DWORD;
    ulCntChar: DWORD;
    rgString: array[0..0] of WideChar;
  end;
const RemSNB = extern struct {
    ulCntStr: u32,
    ulCntChar: u32,
    rgString: [1]u16,
};
type
  RemSNB {.bycopy.} = object
    ulCntStr: uint32
    ulCntChar: uint32
    rgString: array[1, uint16]
struct RemSNB
{
    uint ulCntStr;
    uint ulCntChar;
    wchar[1] rgString;
}

HSP用 定義

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

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

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