Registering components

You register an EXE server by running it. You can check this out with the SieveBasExeN program. Open the Registry Editor, and then find the SieveBasExeN.CSieveBasExeN class using the Find menu item (on the Search, View, or Edit menu, depending on your registry editor). Delete the entry. The Sieve is gone. Now run the SieveServerEXE program. Restart or refresh the Registry Editor. The Sieve is back.

By using the command-line options /regserver and /unregserver, you can register or unregister any COM EXE server without invoking the programís normal user interface. If you want to register SieveBasExeN.EXE without taking over the userís screen, you can do it from your setup program with this statement:

Shell "SieveBasExeN.EXE /regserver"

It seems a little strange that all your ActiveX EXE components are able to recognize command-line options without any programming by you, but itís part of the COM library code that is added to a program when you specify that a program should be an ActiveX component.

Setup programs created with the Setup Toolkit will automatically register your components. As a practical matter, this issue affects you, not your customers. Chances are youíll run your EXE server program from the IDE sometime during development of the program. It will be registered automatically, and youíll have no trouble. Then youíll put the client and server programs on a disk for
a fellow programmer who also runs Visual Basic (thus bypassing setup). Your client program will fail rudely because the server isnít registered on your colleagueís disk. The workaround is easy; just tell your colleague to run the server program once before running the client.

Now try running a DLL server with the /regserver command-line option:

SieveBasDllN.DLL /regserver

Ha! You know better than to run a DLL. Never mind. Hidden away in the \Tools\RegUtils directory on your Visual Basic distribution CD (not copied to your disk during setup) are several registration programs, including REGSVR32.EXE. Hereís the real command line to register your DLL:

regsvr32 SieveBasDllN.DLL

REGSVR32 has a /u option to unregister a server and a /s (silent) option to register a server without displaying a success dialog box. The setup programs created by the Setup Toolkit can handle this registration for your customers. When you choose the Make DLL File menu item, Visual Basic automatically registers the DLL. In other words, you usually wonít need to call REGSVR32, but itís there if you really need it.