ホーム › NetworkManagement.NetManagement › FLAT_STRING
FLAT_STRING
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| MaximumLength | SHORT | 2 | +0 | +0 | バッファに格納可能な最大バイト数を示す(符号付き16ビット)。 |
| Length | SHORT | 2 | +2 | +2 | 現在格納されている文字列のバイト長を示す(符号付き16ビット)。 |
| Buffer | CHAR | 1 | +4 | +4 | 文字列データを格納する可変長バッファの先頭文字を示す。 |
各言語での定義
#include <windows.h>
// FLAT_STRING (x64 6 / x86 6 バイト)
typedef struct FLAT_STRING {
SHORT MaximumLength;
SHORT Length;
CHAR Buffer[1];
} FLAT_STRING;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FLAT_STRING
{
public short MaximumLength;
public short Length;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public sbyte[] Buffer;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FLAT_STRING
Public MaximumLength As Short
Public Length As Short
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Buffer() As SByte
End Structureimport ctypes
from ctypes import wintypes
class FLAT_STRING(ctypes.Structure):
_fields_ = [
("MaximumLength", ctypes.c_short),
("Length", ctypes.c_short),
("Buffer", ctypes.c_byte * 1),
]#[repr(C)]
pub struct FLAT_STRING {
pub MaximumLength: i16,
pub Length: i16,
pub Buffer: [i8; 1],
}import "golang.org/x/sys/windows"
type FLAT_STRING struct {
MaximumLength int16
Length int16
Buffer [1]int8
}type
FLAT_STRING = record
MaximumLength: Smallint;
Length: Smallint;
Buffer: array[0..0] of Shortint;
end;const FLAT_STRING = extern struct {
MaximumLength: i16,
Length: i16,
Buffer: [1]i8,
};type
FLAT_STRING {.bycopy.} = object
MaximumLength: int16
Length: int16
Buffer: array[1, int8]struct FLAT_STRING
{
short MaximumLength;
short Length;
byte[1] Buffer;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; FLAT_STRING サイズ: 6 バイト(x64)
dim st, 2 ; 4byte整数×2(構造体サイズ 6 / 4 切り上げ)
; MaximumLength : SHORT (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; Length : SHORT (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; Buffer : CHAR (+4, 1byte) varptr(st)+4 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global FLAT_STRING
#field short MaximumLength
#field short Length
#field byte Buffer 1
#endstruct
stdim st, FLAT_STRING ; NSTRUCT 変数を確保
st->MaximumLength = 100
mes "MaximumLength=" + st->MaximumLength