OWLNext 7.0
Borland's Object Windows Library for the modern age
|
When OLE invokes a server, it places an -Embedding switch on the command line to tell the application why it has been invoked.
The presence of the switch indicates that the user did not launch the server directly. Usually a server responds by keeping its main window hidden. The user interacts with the server through the container. If the -Embedding switch is not present, the user has invoked the server as a standalone application and the server shows itself in the normal way.
When you construct a TRegistrar object, it parses the command line for you and searches for any OLE-related switches. It removes the switches as it processes them, so if you examine your command line after creating TRegistrar you will never see them.
If you want to know what switches were found, call IsOptionSet. For example, this line tests for the presence of a registration switch on the command line:
This is a common test in OwlMain. If the a command line switch such as -RegServer was set, the application simply quits. By the time the registrar object is constructed, any registration action requested on the command line have already been performed.
The following table lists all the OLE-related command-line switches
Switch | What the server should do | OLE places switch? |
/RegServer | Register all its information and quit | No |
/UnregServer | Remove all its entries from the system and quit | No |
/NoRegValidate | Run without confirming entries in the system database | No |
/Automation | Register itself as single-use (one client only). Always accompanied by -Embedding | Yes |
/Embedding | Consider remaining hidden because it is running for a client, not for itself | Yes |
/Language | Set the language for registration and type libraries | No |
/TypeLib | Create and register a type library | No |
/Debug | Enter a debugging session | Yes |
OLE places some of the switches on the program's command line. Anyone can set other flags to make ObjectComponents perform specific tasks. An install program, for example, might invoke the application it installs and pass it the -RegServer switch to make the server register itself. Switches can begin with either a hyphen (-) or a slash (/).
Only a few of the switches call for any action from you. If a server or an automation object sees the -Embedding or -Automation switch, it might decide to keep its main window hidden. Usually ObjectComponents makes that decision for you. You can use the -Debug switch as a signal to turn trace messages on and off, but responding to -Debug is always optional. (OLE uses -Debug switch only if you register the debugprogid key.)
ObjectComponents handles all the other switches for you. If the user calls a program with the -UnregServer switch, ObjectComponents examines its registration tables and erases all its entries from the registration database. If ObjectComponents finds a series of switches on the command line, it processes them all. This example makes ObjectComponents generate a type libary in the default language and then again in Belgian French.
the number passed to -Language must be hexadecimal digits. The Win32 API defines 80C as the locale ID for the Belgian dialect of the French language. For this command line to have the desired effect, of course, myapp must supply Belgian French strings in its XLAT resources.
The -RegServer flag optionally accepts a file name.
This causes ObjectComponents to create a registration data file in MYAPP.REG. The new file contains all the application's registration data. If you distribute MYAPP.REG with your program, users can merge the file directly into their own registration database (using RegEdit). Without a file name, -RegServer writes all data directly to the system's registration database.