Win32 API 日本語リファレンス
ホームMedia.WindowsMediaFormat › WMT_WEBSTREAM_SAMPLE_HEADER

WMT_WEBSTREAM_SAMPLE_HEADER

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

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

フィールド

フィールドサイズx64x86説明
cbLengthWORD2+0+0このサンプルヘッダの長さをバイトで示す。
wPartWORD2+2+2分割サンプルの現在の部分番号。
cTotalPartsWORD2+4+4サンプル全体の分割部分総数。
wSampleTypeWORD2+6+6サンプルの種類を示す値。
wszURLWCHAR2+8+8関連付けられたリソースのURL文字列。

各言語での定義

#include <windows.h>

// WMT_WEBSTREAM_SAMPLE_HEADER  (x64 10 / x86 10 バイト)
typedef struct WMT_WEBSTREAM_SAMPLE_HEADER {
    WORD cbLength;
    WORD wPart;
    WORD cTotalParts;
    WORD wSampleType;
    WCHAR wszURL[1];
} WMT_WEBSTREAM_SAMPLE_HEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WMT_WEBSTREAM_SAMPLE_HEADER
{
    public ushort cbLength;
    public ushort wPart;
    public ushort cTotalParts;
    public ushort wSampleType;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] public string wszURL;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WMT_WEBSTREAM_SAMPLE_HEADER
    Public cbLength As UShort
    Public wPart As UShort
    Public cTotalParts As UShort
    Public wSampleType As UShort
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)> Public wszURL As String
End Structure
import ctypes
from ctypes import wintypes

class WMT_WEBSTREAM_SAMPLE_HEADER(ctypes.Structure):
    _fields_ = [
        ("cbLength", ctypes.c_ushort),
        ("wPart", ctypes.c_ushort),
        ("cTotalParts", ctypes.c_ushort),
        ("wSampleType", ctypes.c_ushort),
        ("wszURL", ctypes.c_wchar * 1),
    ]
#[repr(C)]
pub struct WMT_WEBSTREAM_SAMPLE_HEADER {
    pub cbLength: u16,
    pub wPart: u16,
    pub cTotalParts: u16,
    pub wSampleType: u16,
    pub wszURL: [u16; 1],
}
import "golang.org/x/sys/windows"

type WMT_WEBSTREAM_SAMPLE_HEADER struct {
	cbLength uint16
	wPart uint16
	cTotalParts uint16
	wSampleType uint16
	wszURL [1]uint16
}
type
  WMT_WEBSTREAM_SAMPLE_HEADER = record
    cbLength: Word;
    wPart: Word;
    cTotalParts: Word;
    wSampleType: Word;
    wszURL: array[0..0] of WideChar;
  end;
const WMT_WEBSTREAM_SAMPLE_HEADER = extern struct {
    cbLength: u16,
    wPart: u16,
    cTotalParts: u16,
    wSampleType: u16,
    wszURL: [1]u16,
};
type
  WMT_WEBSTREAM_SAMPLE_HEADER {.bycopy.} = object
    cbLength: uint16
    wPart: uint16
    cTotalParts: uint16
    wSampleType: uint16
    wszURL: array[1, uint16]
struct WMT_WEBSTREAM_SAMPLE_HEADER
{
    ushort cbLength;
    ushort wPart;
    ushort cTotalParts;
    ushort wSampleType;
    wchar[1] wszURL;
}

HSP用 定義

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

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

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