Delphi または RIDL 構文の使用

提供: RAD Studio
移動先: 案内検索

タイプ ライブラリ エディタの使用 への移動


タイプ ライブラリ エディタの[コード]ページには、型情報が RIDL 形式(制限付きインターフェイス定義言語)で表示されます。 この形式は Microsoft の IDL 構文に似ています。 しかし、RIDL がサポートするのは IDL の一部のみです。 Delphi アプリケーション全般と同様、タイプ ライブラリ内の識別子は大文字小文字を区別しません。 識別子の長さは最大 255 文字で、移植性を最大とするため、英字または下線(_)で始めてください。

属性の指定

RIDL ファイルで宣言されている型には、属性を含める場合があります。 属性の指定は、角括弧で囲み、コンマで区切ります。 属性の指定はそれぞれ、属性名と(該当する場合には)それに続く値で構成されます。

次の表に、属性名とそれに対応する値を示します。

属性の構文

属性名 適用先

aggregatable

[aggregatable]

typeInfo

appobject

[appobject]

CoClass 型情報

bindable

[bindable]

CoClass メンバを除くメンバ

[コントロール]

[control]

タイプ ライブラリ、型情報

[カスタム]

[custom '{7B5687A1-F4E9-11D1-92A8-00C04F8C8FC4}' 0]

任意

[デフォルト]

[default]

CoClass メンバ

defaultbind

[defaultbind]

CoClass メンバを除くメンバ

defaultcollection

[defaultcollection]

CoClass メンバを除くメンバ

dispid

[dispid]

CoClass メンバを除くメンバ

displaybind

[displaybind]

CoClass メンバを除くメンバ

dllname

[dllname 'Helper.dll']

モジュール型情報

dual

[dual]

インターフェイス型情報

helpfile

[helpfile 'c:\help\myhelp.chm'] [helpfile 'c:\help\myhelp.hlp']

タイプ ライブラリ

helpstringdll

[helpstringdll 'c:\help\myhelp.dll']

タイプ ライブラリ

helpcontext

[helpcontext 2005]

CoClass メンバとパラメータを除いて任意

helpstring

[helpstring 'payroll interface']

CoClass メンバとパラメータを除いて任意

helpstringcontext

[helpstringcontext $17]

CoClass メンバとパラメータを除いて任意

hidden

[hidden]

パラメータを除いて任意

lcid

[lcid $324]

タイプ ライブラリ

licensed

[licensed]

タイプ ライブラリ、CoClass 型情報

nonbrowsable

[nonbrowsable]

CoClass メンバを除くメンバ

nonextensible

[nonextensible]

インターフェイス型情報

oleautomation

[oleautomation]

インターフェイス型情報

predeclid

[predeclid]

typeInfo

propget

[propget]

CoClass メンバを除くメンバ

propput

[propput]

CoClass メンバを除くメンバ

propputref

[propputref]

CoClass メンバを除くメンバ

[Public]

[public]

エイリアス型情報

ReadOnly

[readonly]

CoClass メンバを除くメンバ

replaceable

[replaceable]

CoClass メンバとパラメータを除いて任意

requestedit

[requestedit]

CoClass メンバを除くメンバ

restricted

[restricted]

パラメータを除いて任意

source

[source]

すべてのメンバ

uidefault

[uidefault]

CoClass メンバを除くメンバ

usesgetlasterror

[usesgetlasterror]

CoClass メンバを除くメンバ

uuid

[uuid '{7B5687A1-F4E9-11D1-92A8-00C04F8C8FC4}' ]

タイプ ライブラリ、型情報(必須)

vararg

[vararg]

CoClass メンバを除くメンバ

バージョン

[version 1.1]

タイプ ライブラリ、型情報

インターフェイス構文

interface 型情報の宣言を行う Delphi 構文の形式は、次のとおりです。

interfacename = interface[(baseinterface)] [attributes]
functionlist
[propertymethodlist]
end;

たとえば次の文は、メソッドを 2 つ、プロパティを 1 つ持つインターフェイスを宣言しています。

Interface1 = interface (IDispatch)
  [uuid '{7B5687A1-F4E9-11D1-92A8-00C04F8C8FC4}', version 1.0]
  function Calculate(optional seed:Integer=0): Integer;
  procedure Reset;
  procedure PutRange(Range: Integer) [propput, dispid $00000005]; stdcall;
  function GetRange: Integer;[propget, dispid $00000005]; stdcall;
end;

これに対応する Microsoft IDL の構文は次のとおりです。

[uuid '{5FD36EEF-70E5-11D1-AA62-00C04FB16F42}',version 1.0]
interface Interface1 :IDispatch
{
  long Calculate([in, optional, defaultvalue(0)] long seed);
  void Reset(void);
  [propput, id(0x00000005)] void _stdcall PutRange([in] long Value);
  [propput, id(0x00000005)] void _stdcall getRange([out, retval] long *Value);
};

ディスパッチ インターフェイス構文

disinterface 型情報の宣言を行う Delphi 構文の形式は、次のとおりです。

dispinterfacename = dispinterface [attributes]
functionlist
[propertylist]
end;

たとえば次の文は、前出のインターフェイスと同じメソッドとプロパティを持つディスパッチ インターフェイスを宣言しています。

MyDispObj = dispinterface
[uuid '{5FD36EEF-70E5-11D1-AA62-00C04FB16F42}',
  version 1.0,
  helpstring 'dispatch interface for MyObj'
  function Calculate(seed:Integer): Integer [dispid 1];
  procedure Reset [dispid 2];
  property Range: Integer [dispid 3];
end;

これに対応する Microsoft IDL の構文は次のとおりです。

[uuid '{5FD36EEF-70E5-11D1-AA62-00C04FB16F42}',
  version 1.0,
  helpstring "dispatch interface for MyObj"
dispinterface Interface1
{
  methods:
    [id(1)] int Calculate([in] int seed);
    [id(2)] void Reset(void);
  properties:
    [id(3)] int Value;
};

CoClass 構文

CoClass 型情報の宣言を行う Delphi 構文の形式は、次のとおりです。

classname = coclass(interfacename[interfaceattributes], ...); [attributes];

たとえば次の文は、インターフェイス IMyInt とディスパッチ インターフェイス DmyInt の CoClass を宣言しています。

myapp = coclass(IMyInt [source], DMyInt);
[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
  version 1.0,
  helpstring 'A class',
  appobject]

これに対応する Microsoft IDL の構文は次のとおりです。

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
  version 1.0,
  helpstring "A class",
  appobject]
coclass myapp
{
  methods:
  [source] interface IMyInt);
  dispinterface DMyInt;
};

列挙型構文

Enum 型情報の宣言を行う Delphi 構文の形式は、次のとおりです。

enumname = ([attributes] enumlist);

たとえば次の文は、3 個の値を持つ列挙型を宣言しています。

location = ([uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
         helpstring 'location of booth']
  Inside = 1 [helpstring 'Inside the pavillion'];
  Outside = 2 [helpstring 'Outside the pavillion'];
  Offsite = 3 [helpstring 'Not near the pavillion'];);

これに対応する Microsoft IDL の構文は次のとおりです。

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
        helpstring "location of booth"]
typedef enum
{
  [helpstring "Inside the pavillion"] Inside = 1,
  [helpstring "Outside the pavillion"] Outside = 2,
  [helpstring "Not near the pavillion"] Offsite = 3
} location;

エイリアス構文

Alias 型情報の宣言を行う Delphi 構文の形式は、次のとおりです。

aliasname = basetype[attributes];

たとえば次の文は、整数のエイリアスとして DWORD を宣言しています。

DWORD = Integer [uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}'];

これに対応する Microsoft IDL の構文は次のとおりです。

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}'] typedef long DWORD;

レコード構文

Record 型情報の宣言を行う Delphi 構文の形式は、次のとおりです。

recordname = record [attributes] fieldlist end;

たとえば次の文は、レコードを宣言しています。

Tasks = record [uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
                helpstring 'Task description']
  ID: Integer;
  StartDate: TDate;
  EndDate: TDate;
  Ownername: WideString;
  Subtasks: safearray of Integer;
end;

これに対応する Microsoft IDL の構文は次のとおりです。

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
        helpstring "Task description"]
typedef struct
{
  long ID;
  DATE StartDate;
  DATE EndDate;
  BSTR Ownername;
  SAFEARRAY (int) Subtasks;
} Tasks;

ユニオン構文

Union 型情報の宣言を行う Delphi 構文の形式は、次のとおりです。

unionname = record [attributes]
case Integer of
  0: field1;
  1: field2;
  ...
end;

たとえば次の文は、ユニオンを宣言しています。

MyUnion = record [uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
                  helpstring "item description"]
case Integer of
  0: (Name: WideString);
  1: (ID: Integer);
  3: (Value: Double);
end;

これに対応する Microsoft IDL の構文は次のとおりです。

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
        helpstring "item description"]
typedef union
{
  BSTR Name;
  long ID;
  double Value;
  } MyUnion;

モジュール構文

Module 型情報の宣言を行う Delphi 構文の形式は、次のとおりです。

modulename = module constants entrypoints end;

たとえば次の文は、モジュールの型情報を宣言しています。

MyModule = module [uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
                   dllname 'circle.dll']
  PI: Double = 3.14159;
  function area(radius: Double): Double [ entry 1 ]; stdcall;
  function circumference(radius: Double): Double [ entry 2 ]; stdcall;
end;

これに対応する Microsoft IDL の構文は次のとおりです。

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
        dllname("circle.dll")]
module MyModule
{
  double PI = 3.14159;
  [entry(1)] double _stdcall area([in] double radius);
  [entry(2)] double _stdcall circumference([in] double radius);
};

トピック

関連項目