ホーム › NetworkManagement.NetBios › NCB
NCB
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ncb_command | BYTE | 1 | +0 | +0 | 実行するNetBIOSコマンドコード。最上位ビットで非同期実行を指定。 |
| ncb_retcode | BYTE | 1 | +1 | +1 | コマンドの戻りコード(完了ステータス)。 |
| ncb_lsn | BYTE | 1 | +2 | +2 | ローカルセッション番号。 |
| ncb_num | BYTE | 1 | +3 | +3 | ローカルネットワーク名に割り当てられた番号。 |
| ncb_buffer | BYTE* | 8/4 | +8 | +4 | メッセージデータの送受信バッファへのポインタ。 |
| ncb_length | WORD | 2 | +16 | +8 | ncb_bufferのサイズ(バイト)。 |
| ncb_callname | BYTE | 16 | +18 | +10 | 通信相手のリモート名(16バイト)。 |
| ncb_name | BYTE | 16 | +34 | +26 | ローカル側の名前(16バイト)。 |
| ncb_rto | BYTE | 1 | +50 | +42 | 受信タイムアウト(500ミリ秒単位)。 |
| ncb_sto | BYTE | 1 | +51 | +43 | 送信タイムアウト(500ミリ秒単位)。 |
| ncb_post | INT_PTR | 8/4 | +56 | +44 | 非同期完了時に呼ばれるコールバック関数へのポインタ。 |
| ncb_lana_num | BYTE | 1 | +64 | +48 | 対象LANアダプタ番号。 |
| ncb_cmd_cplt | BYTE | 1 | +65 | +49 | コマンド完了状態(0xFFは実行中)。 |
| ncb_reserve | BYTE | 10 | +66 | +50 | 予約フィールド。0を設定する。 |
| ncb_event | HANDLE | 8/4 | +80 | +60 | 非同期完了時にシグナルされるイベントハンドル。 |
各言語での定義
#include <windows.h>
// NCB (x64 88 / x86 64 バイト)
typedef struct NCB {
BYTE ncb_command;
BYTE ncb_retcode;
BYTE ncb_lsn;
BYTE ncb_num;
BYTE* ncb_buffer;
WORD ncb_length;
BYTE ncb_callname[16];
BYTE ncb_name[16];
BYTE ncb_rto;
BYTE ncb_sto;
INT_PTR ncb_post;
BYTE ncb_lana_num;
BYTE ncb_cmd_cplt;
BYTE ncb_reserve[10];
HANDLE ncb_event;
} NCB;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NCB
{
public byte ncb_command;
public byte ncb_retcode;
public byte ncb_lsn;
public byte ncb_num;
public IntPtr ncb_buffer;
public ushort ncb_length;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] ncb_callname;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] ncb_name;
public byte ncb_rto;
public byte ncb_sto;
public IntPtr ncb_post;
public byte ncb_lana_num;
public byte ncb_cmd_cplt;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public byte[] ncb_reserve;
public IntPtr ncb_event;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NCB
Public ncb_command As Byte
Public ncb_retcode As Byte
Public ncb_lsn As Byte
Public ncb_num As Byte
Public ncb_buffer As IntPtr
Public ncb_length As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public ncb_callname() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public ncb_name() As Byte
Public ncb_rto As Byte
Public ncb_sto As Byte
Public ncb_post As IntPtr
Public ncb_lana_num As Byte
Public ncb_cmd_cplt As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=10)> Public ncb_reserve() As Byte
Public ncb_event As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class NCB(ctypes.Structure):
_fields_ = [
("ncb_command", ctypes.c_ubyte),
("ncb_retcode", ctypes.c_ubyte),
("ncb_lsn", ctypes.c_ubyte),
("ncb_num", ctypes.c_ubyte),
("ncb_buffer", ctypes.c_void_p),
("ncb_length", ctypes.c_ushort),
("ncb_callname", ctypes.c_ubyte * 16),
("ncb_name", ctypes.c_ubyte * 16),
("ncb_rto", ctypes.c_ubyte),
("ncb_sto", ctypes.c_ubyte),
("ncb_post", ctypes.c_ssize_t),
("ncb_lana_num", ctypes.c_ubyte),
("ncb_cmd_cplt", ctypes.c_ubyte),
("ncb_reserve", ctypes.c_ubyte * 10),
("ncb_event", ctypes.c_void_p),
]#[repr(C)]
pub struct NCB {
pub ncb_command: u8,
pub ncb_retcode: u8,
pub ncb_lsn: u8,
pub ncb_num: u8,
pub ncb_buffer: *mut core::ffi::c_void,
pub ncb_length: u16,
pub ncb_callname: [u8; 16],
pub ncb_name: [u8; 16],
pub ncb_rto: u8,
pub ncb_sto: u8,
pub ncb_post: isize,
pub ncb_lana_num: u8,
pub ncb_cmd_cplt: u8,
pub ncb_reserve: [u8; 10],
pub ncb_event: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type NCB struct {
ncb_command byte
ncb_retcode byte
ncb_lsn byte
ncb_num byte
ncb_buffer uintptr
ncb_length uint16
ncb_callname [16]byte
ncb_name [16]byte
ncb_rto byte
ncb_sto byte
ncb_post uintptr
ncb_lana_num byte
ncb_cmd_cplt byte
ncb_reserve [10]byte
ncb_event uintptr
}type
NCB = record
ncb_command: Byte;
ncb_retcode: Byte;
ncb_lsn: Byte;
ncb_num: Byte;
ncb_buffer: Pointer;
ncb_length: Word;
ncb_callname: array[0..15] of Byte;
ncb_name: array[0..15] of Byte;
ncb_rto: Byte;
ncb_sto: Byte;
ncb_post: NativeInt;
ncb_lana_num: Byte;
ncb_cmd_cplt: Byte;
ncb_reserve: array[0..9] of Byte;
ncb_event: Pointer;
end;const NCB = extern struct {
ncb_command: u8,
ncb_retcode: u8,
ncb_lsn: u8,
ncb_num: u8,
ncb_buffer: ?*anyopaque,
ncb_length: u16,
ncb_callname: [16]u8,
ncb_name: [16]u8,
ncb_rto: u8,
ncb_sto: u8,
ncb_post: isize,
ncb_lana_num: u8,
ncb_cmd_cplt: u8,
ncb_reserve: [10]u8,
ncb_event: ?*anyopaque,
};type
NCB {.bycopy.} = object
ncb_command: uint8
ncb_retcode: uint8
ncb_lsn: uint8
ncb_num: uint8
ncb_buffer: pointer
ncb_length: uint16
ncb_callname: array[16, uint8]
ncb_name: array[16, uint8]
ncb_rto: uint8
ncb_sto: uint8
ncb_post: int
ncb_lana_num: uint8
ncb_cmd_cplt: uint8
ncb_reserve: array[10, uint8]
ncb_event: pointerstruct NCB
{
ubyte ncb_command;
ubyte ncb_retcode;
ubyte ncb_lsn;
ubyte ncb_num;
void* ncb_buffer;
ushort ncb_length;
ubyte[16] ncb_callname;
ubyte[16] ncb_name;
ubyte ncb_rto;
ubyte ncb_sto;
ptrdiff_t ncb_post;
ubyte ncb_lana_num;
ubyte ncb_cmd_cplt;
ubyte[10] ncb_reserve;
void* ncb_event;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NCB サイズ: 64 バイト(x86)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; ncb_command : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; ncb_retcode : BYTE (+1, 1byte) poke st,1,値 / 値 = peek(st,1)
; ncb_lsn : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; ncb_num : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; ncb_buffer : BYTE* (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; ncb_length : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; ncb_callname : BYTE (+10, 16byte) varptr(st)+10 を基点に操作(16byte:入れ子/配列)
; ncb_name : BYTE (+26, 16byte) varptr(st)+26 を基点に操作(16byte:入れ子/配列)
; ncb_rto : BYTE (+42, 1byte) poke st,42,値 / 値 = peek(st,42)
; ncb_sto : BYTE (+43, 1byte) poke st,43,値 / 値 = peek(st,43)
; ncb_post : INT_PTR (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; ncb_lana_num : BYTE (+48, 1byte) poke st,48,値 / 値 = peek(st,48)
; ncb_cmd_cplt : BYTE (+49, 1byte) poke st,49,値 / 値 = peek(st,49)
; ncb_reserve : BYTE (+50, 10byte) varptr(st)+50 を基点に操作(10byte:入れ子/配列)
; ncb_event : HANDLE (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NCB サイズ: 88 バイト(x64)
dim st, 22 ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; ncb_command : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; ncb_retcode : BYTE (+1, 1byte) poke st,1,値 / 値 = peek(st,1)
; ncb_lsn : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; ncb_num : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; ncb_buffer : BYTE* (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; ncb_length : WORD (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; ncb_callname : BYTE (+18, 16byte) varptr(st)+18 を基点に操作(16byte:入れ子/配列)
; ncb_name : BYTE (+34, 16byte) varptr(st)+34 を基点に操作(16byte:入れ子/配列)
; ncb_rto : BYTE (+50, 1byte) poke st,50,値 / 値 = peek(st,50)
; ncb_sto : BYTE (+51, 1byte) poke st,51,値 / 値 = peek(st,51)
; ncb_post : INT_PTR (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; ncb_lana_num : BYTE (+64, 1byte) poke st,64,値 / 値 = peek(st,64)
; ncb_cmd_cplt : BYTE (+65, 1byte) poke st,65,値 / 値 = peek(st,65)
; ncb_reserve : BYTE (+66, 10byte) varptr(st)+66 を基点に操作(10byte:入れ子/配列)
; ncb_event : HANDLE (+80, 8byte) qpoke st,80,値 / qpeek(st,80) ※IronHSPのみ。3.7/3.8は lpoke st,80,下位 : lpoke st,84,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NCB
#field byte ncb_command
#field byte ncb_retcode
#field byte ncb_lsn
#field byte ncb_num
#field intptr ncb_buffer
#field short ncb_length
#field byte ncb_callname 16
#field byte ncb_name 16
#field byte ncb_rto
#field byte ncb_sto
#field intptr ncb_post
#field byte ncb_lana_num
#field byte ncb_cmd_cplt
#field byte ncb_reserve 10
#field intptr ncb_event
#endstruct
stdim st, NCB ; NSTRUCT 変数を確保
st->ncb_command = 100
mes "ncb_command=" + st->ncb_command