ホーム › NetworkManagement.Ndis › IF_COUNTED_STRING_LH
IF_COUNTED_STRING_LH
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Length | WORD | 2 | +0 | +0 | String内の有効な文字列の長さ(バイト数)である。 |
| String | WCHAR | 514 | +2 | +2 | 長さ付きで保持されるワイド文字列バッファである。 |
各言語での定義
#include <windows.h>
// IF_COUNTED_STRING_LH (x64 516 / x86 516 バイト)
typedef struct IF_COUNTED_STRING_LH {
WORD Length;
WCHAR String[257];
} IF_COUNTED_STRING_LH;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IF_COUNTED_STRING_LH
{
public ushort Length;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 257)] public string String;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IF_COUNTED_STRING_LH
Public Length As UShort
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public String As String
End Structureimport ctypes
from ctypes import wintypes
class IF_COUNTED_STRING_LH(ctypes.Structure):
_fields_ = [
("Length", ctypes.c_ushort),
("String", ctypes.c_wchar * 257),
]#[repr(C)]
pub struct IF_COUNTED_STRING_LH {
pub Length: u16,
pub String: [u16; 257],
}import "golang.org/x/sys/windows"
type IF_COUNTED_STRING_LH struct {
Length uint16
String [257]uint16
}type
IF_COUNTED_STRING_LH = record
Length: Word;
String: array[0..256] of WideChar;
end;const IF_COUNTED_STRING_LH = extern struct {
Length: u16,
String: [257]u16,
};type
IF_COUNTED_STRING_LH {.bycopy.} = object
Length: uint16
String: array[257, uint16]struct IF_COUNTED_STRING_LH
{
ushort Length;
wchar[257] String;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IF_COUNTED_STRING_LH サイズ: 516 バイト(x64)
dim st, 129 ; 4byte整数×129(構造体サイズ 516 / 4 切り上げ)
; Length : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; String : WCHAR (+2, 514byte) varptr(st)+2 を基点に操作(514byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IF_COUNTED_STRING_LH
#field short Length
#field wchar String 257
#endstruct
stdim st, IF_COUNTED_STRING_LH ; NSTRUCT 変数を確保
st->Length = 100
mes "Length=" + st->Length