Win32 API 日本語リファレンス
ホームSystem.Ole › OBJECTDESCRIPTOR

OBJECTDESCRIPTOR

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

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

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のサイズをバイト単位で表す。
clsidGUID16+4+4オブジェクトのクラスID(CLSID)である。不明な場合はCLSID_NULL。
dwDrawAspectDWORD4+20+20オブジェクトの表示アスペクト(DVASPECT値)である。
sizelSIZE8+24+24オブジェクトのサイズをHIMETRIC単位で表すSIZEである。
pointlPOINTL8+32+32ドラッグ時のマウス位置を示すPOINTLである。未使用時は(0,0)。
dwStatusDWORD4+40+40オブジェクトのステータスフラグ(OLEMISC値)である。
dwFullUserTypeNameDWORD4+44+44完全なユーザータイプ名文字列への構造体先頭からのオフセットである。0で無し。
dwSrcOfCopyDWORD4+48+48コピー元を示す文字列へのオフセットである。0で無し。

各言語での定義

#include <windows.h>

// SIZE  (x64 8 / x86 8 バイト)
typedef struct SIZE {
    INT cx;
    INT cy;
} SIZE;

// POINTL  (x64 8 / x86 8 バイト)
typedef struct POINTL {
    INT x;
    INT y;
} POINTL;

// OBJECTDESCRIPTOR  (x64 52 / x86 52 バイト)
typedef struct OBJECTDESCRIPTOR {
    DWORD cbSize;
    GUID clsid;
    DWORD dwDrawAspect;
    SIZE sizel;
    POINTL pointl;
    DWORD dwStatus;
    DWORD dwFullUserTypeName;
    DWORD dwSrcOfCopy;
} OBJECTDESCRIPTOR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SIZE
{
    public int cx;
    public int cy;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINTL
{
    public int x;
    public int y;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OBJECTDESCRIPTOR
{
    public uint cbSize;
    public Guid clsid;
    public uint dwDrawAspect;
    public SIZE sizel;
    public POINTL pointl;
    public uint dwStatus;
    public uint dwFullUserTypeName;
    public uint dwSrcOfCopy;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SIZE
    Public cx As Integer
    Public cy As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINTL
    Public x As Integer
    Public y As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure OBJECTDESCRIPTOR
    Public cbSize As UInteger
    Public clsid As Guid
    Public dwDrawAspect As UInteger
    Public sizel As SIZE
    Public pointl As POINTL
    Public dwStatus As UInteger
    Public dwFullUserTypeName As UInteger
    Public dwSrcOfCopy As UInteger
End Structure
import ctypes
from ctypes import wintypes

class SIZE(ctypes.Structure):
    _fields_ = [
        ("cx", ctypes.c_int),
        ("cy", ctypes.c_int),
    ]

class POINTL(ctypes.Structure):
    _fields_ = [
        ("x", ctypes.c_int),
        ("y", ctypes.c_int),
    ]

class OBJECTDESCRIPTOR(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("clsid", GUID),
        ("dwDrawAspect", wintypes.DWORD),
        ("sizel", SIZE),
        ("pointl", POINTL),
        ("dwStatus", wintypes.DWORD),
        ("dwFullUserTypeName", wintypes.DWORD),
        ("dwSrcOfCopy", wintypes.DWORD),
    ]
#[repr(C)]
pub struct SIZE {
    pub cx: i32,
    pub cy: i32,
}

#[repr(C)]
pub struct POINTL {
    pub x: i32,
    pub y: i32,
}

#[repr(C)]
pub struct OBJECTDESCRIPTOR {
    pub cbSize: u32,
    pub clsid: GUID,
    pub dwDrawAspect: u32,
    pub sizel: SIZE,
    pub pointl: POINTL,
    pub dwStatus: u32,
    pub dwFullUserTypeName: u32,
    pub dwSrcOfCopy: u32,
}
import "golang.org/x/sys/windows"

type SIZE struct {
	cx int32
	cy int32
}

type POINTL struct {
	x int32
	y int32
}

type OBJECTDESCRIPTOR struct {
	cbSize uint32
	clsid windows.GUID
	dwDrawAspect uint32
	sizel SIZE
	pointl POINTL
	dwStatus uint32
	dwFullUserTypeName uint32
	dwSrcOfCopy uint32
}
type
  SIZE = record
    cx: Integer;
    cy: Integer;
  end;

  POINTL = record
    x: Integer;
    y: Integer;
  end;

  OBJECTDESCRIPTOR = record
    cbSize: DWORD;
    clsid: TGUID;
    dwDrawAspect: DWORD;
    sizel: SIZE;
    pointl: POINTL;
    dwStatus: DWORD;
    dwFullUserTypeName: DWORD;
    dwSrcOfCopy: DWORD;
  end;
const SIZE = extern struct {
    cx: i32,
    cy: i32,
};

const POINTL = extern struct {
    x: i32,
    y: i32,
};

const OBJECTDESCRIPTOR = extern struct {
    cbSize: u32,
    clsid: GUID,
    dwDrawAspect: u32,
    sizel: SIZE,
    pointl: POINTL,
    dwStatus: u32,
    dwFullUserTypeName: u32,
    dwSrcOfCopy: u32,
};
type
  SIZE {.bycopy.} = object
    cx: int32
    cy: int32

  POINTL {.bycopy.} = object
    x: int32
    y: int32

  OBJECTDESCRIPTOR {.bycopy.} = object
    cbSize: uint32
    clsid: GUID
    dwDrawAspect: uint32
    sizel: SIZE
    pointl: POINTL
    dwStatus: uint32
    dwFullUserTypeName: uint32
    dwSrcOfCopy: uint32
struct SIZE
{
    int cx;
    int cy;
}

struct POINTL
{
    int x;
    int y;
}

struct OBJECTDESCRIPTOR
{
    uint cbSize;
    GUID clsid;
    uint dwDrawAspect;
    SIZE sizel;
    POINTL pointl;
    uint dwStatus;
    uint dwFullUserTypeName;
    uint dwSrcOfCopy;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; OBJECTDESCRIPTOR サイズ: 52 バイト(x64)
dim st, 13    ; 4byte整数×13(構造体サイズ 52 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; clsid : GUID (+4, 16byte)  varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; dwDrawAspect : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; sizel : SIZE (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; pointl : POINTL (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; dwStatus : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; dwFullUserTypeName : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; dwSrcOfCopy : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global SIZE
    #field int cx
    #field int cy
#endstruct

#defstruct global POINTL
    #field int x
    #field int y
#endstruct

#defstruct global OBJECTDESCRIPTOR
    #field int cbSize
    #field GUID clsid
    #field int dwDrawAspect
    #field SIZE sizel
    #field POINTL pointl
    #field int dwStatus
    #field int dwFullUserTypeName
    #field int dwSrcOfCopy
#endstruct

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