module 屬性

模組語句會定義一組函式,通常是一組 DLL 進入點。

[
    attributes
]
module modulename 
{
    elementlist
};

參數

attributes

模組語句之前會接受 [uuid]、[version]、[helpstring]、[helpcoNtext]、[hidden]和 [dllname] 屬性。 如需模組定義之前所接受屬性的詳細資訊,請參閱 OLE Automation 書籍中的 屬性描述。 需要 [dllname] 屬性。 如果省略 [uuid] 屬性,則不會在系統中唯一指定模組。

modulename

模組的名稱。

elementlist

DLL 中每個函式的常數定義和函式原型清單。 函式清單中可以顯示任意數目的函式定義。 函式清單中的函式具有下列形式:

[attributes] returntype [呼叫慣例 funcname] (params) ;

[attributes]const constanttype constname = constval;

const只接受 [helpstring] 和 [helpcoNtext] 屬性。

模組中的函式接受下列屬性:[helpstring]、[helpcoNtext]、[string]、[entry]、[propget]、[propput]、[propput]、[propputref]和 [vararg]。 如果指定 [vararg] ,則最後一個參數必須是 VARIANT 類型的安全陣列。

選擇性呼叫慣例可以是__pascal/_pascal/pascal、__cdecl/_cdecl/cdecl 或 __stdcall/_stdcall/stdcall 的其中一個。 呼叫慣例類型 paramname最多可以包含兩個前置底線。

參數清單是以逗號分隔的清單:

[attributes]

此類型可以是任何先前宣告的類型或內建類型、任何類型的指標,或內建類型的指標。 參數的屬性如下:

[in], [out], [optional]。

如果使用 [選擇性] ,這些參數的類型必須是 VARIANTVARIANT*。

備註

模組的標頭檔 (.h) 輸出是一系列的函式原型。 模組關鍵字和周圍括弧會從標頭 (.h) 檔案輸出中移除,但在原型之前插入批註 (//模組模組名稱) 。 關鍵字 extern 會插入宣告之前。

範例

[
    uuid(12345678-1234-1234-1234-123456789ABC), 
    helpstring("This is not GDI.EXE"), 
    helpcontext(190), 
    dllname("MATH.DLL")
] 
module somemodule
{ 
    [helpstring("Color for the frame")] 
            unsigned long const COLOR_FRAME = 0xH80000006; 
    [helpstring("Not a rectangle but a square"), 
     entry(1)] 
            pascal double square([in] double x); 
};

另請參閱

常量

型別程式庫的內容

dllname

進入

使用 MIDL 產生類型程式庫

helpcontext

helpstring

隱藏

ODL 檔案語法

propget

propput

propputref

string

TYPEFLAGS

uuid

vararg

版本