5.9 Generating Interface Information

This chapter explains the procedures which are necessary to build an OLE server from a dialog with a Control defined as ole_server.

5.9.1 Generating the idl and reg Files

With the ‑writeole <base name> option of the IDM simulation program idm.exe, the files required for registration are generated from a dialog script containing Controls defined as OLE servers. An idl and a reg file are generated.

The following additional options may be used to influence the generation:

With idm.exe <dialog> ‑writeole <file>, the following default entries are written into the registry file <file>.reg if they have not been overwritten by one of the options descibed above

LocalServer32 = "<path of idm.exe> <dialog> /Automation"

TypeLib = "<file>.tlb"

HelpDir = ""

DefIcon = ""

The name of the proxy stub is set to <base name>.dll by default.

5.9.2 Server Registration

Double-clicking the reg file (provided that reg files are linked correctly in the system) or calling regedit.exe with the generated reg file as an argument registers the control with the system.

Example

server.reg server.idl: server.dlg
  $(IDM) server.dlg \
  -localserver "$(IDM) server.dlg -IDMtracefile server.log" \
    -writeole server
  regedit server.reg

In this example, the command line for the server is also specified so that it always generates a trace file. Afterward the server is registered with the system.

5.9.3 Further Processing of the idl File

The idl file generated using the ‑writeole option must be processed using the MIDL compiler that comes with Microsoft Visual Studio. The MIDL compiler generates a proxy DLL from the idl file, which handles the OLE marshaling of the interface. The default path is the output name of -writeole with the extension .dll, but this may be overridden with the option +proxy.

Example

server.tlb server_p.c server_i.c server.h dlldata.c: server.idl
  midl /ms_ext /app_config /c_ext /tlb server.tlb /Zp1 \
    /env win32 /Os server.idl

The files generated with the MIDL compiler must then be compiled with the C compiler and linked to a DLL.