Next: , Up: The COM object implementation   [Contents][Index]


5.1.1 Step 1 - The Resource File

The type library must be embedded in to every COM object in order to let the operating system know how to handle proxying and marshaling of the object when needed. It also provides information to binding generators, visual tools, and scripting languages about the object. This is done by creating and compiling with the GNU windres or Microsoft’s rc followed by res2coff a resource script that contains the line:

1 TypeLib "gnatexample.tlb"

Where gnatexample.tlb would be the name of your type library file. It is also advisable to include a version info resource with a StringFileInfo block containing the value pair OLESelfRegister and a blank to indicate that the COM object container will handle registration of the COM object and type library when requested to do so from the command line for Local Servers or using the utility regsvr32.exe for InProc Servers. For example:

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
 FILEFLAGS 0x0L
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
       BLOCK "040904b0"
       BEGIN
          VALUE "CompanyName", "Your Company Here\0"
          VALUE "FileDescription", "gnatexample\0"
          VALUE "FileVersion", "1, 0, 0, 1\0"
          VALUE "InternalName", "gnatexample\0"
          VALUE "LegalCopyright", "Copyright©\0"
          VALUE "OriginalFilename", "gnatexample\0"
          VALUE "ProductName", "gnatexample\0"
          VALUE "ProductVersion", "1, 0, 0, 1\0"
          VALUE "OLESelfRegister", ""
       END
    END
    BLOCK "VarFileInfo"
    BEGIN
      VALUE "Translation", 0x409, 1200
    END