<HTML> <HEAD><TITLE>Ch 19 - Registering Your Application - Special Edition Using Visual Basic 5</TITLE> </HEAD> <BODY BGCOLOR="#ffffff" TEXT="#000000"> <p><H2><b>Registering Program Manager Icons</b></H2></P> <HR> <P>Associating a file type with your application causes the Program Manager to use your application's default icon for program items created from files with the specified type (see Figure 19.5). <P><a href="figs/19fig05.gif"><B>FIG. 19.5</a></b> <P><i>When you add a program item with the file type .OLE, it is displayed with the icon from OLESTORE.EXE.</i> <P>To use an icon other than the one displayed by default for the application, specify a DefaultIcon key in the application's registration entry file. To do this, follow these steps: <OL> <LI>Add a class module to your application. Name the class module after the last portion of the programmatic ID for your application. For example, if your programmatic ID is OleStore.Application, set the Name property of the class module to Application. <LI>Compile the application into an .EXE file. <LI>Run the .EXE file. When the application runs, it registers a class ID in the Registry for the class module you created in step 2. The following entries are added for the OLESTORE application: <p><pre><tt> <FONT COLOR="#008000">REGEDIT HKEY_CLASSES_ROOT.application= A4C17767-BB44-101B-BADD-4C696E65044C HKEY_CLASSES_ROOT{A4C17767-BB44-101B-BADD-4C696E65044C @= A4C17761-BB44-101B-BADD-4C696E65044C HKEY_CLASSES_ROOT{A4C17767-BB44-101B-BADD-4C696E65044C= OLE2.DLL HKEY_CLASSES_ROOT{A4C17767-BB44-101B-BADD-4C696E65044C@ <BR>= c:
vb5 se
samples
chapter 17
olestore.exe HKEY_CLASSES_ROOT{A4C17767-BB44-101B-BADD-4C696E65044C= olestore.application</FONT></tt></pre> <LI>Add a DefaultIcon key to the class ID key in the Registry. For example, the following key indicates that OLESTORE should use the second icon stored in the application OLESTORE.EXE: <p><pre><tt> <FONT COLOR="#008000">HKEY_CLASSES_ROOT{A4C17767-BB44-101B-BADD-4C696E65044C <BR>@= c:
vb5 se
samples
chapter 17
olestore.exe, 2</FONT></tt></pre> <p>To register this line, you can either add it to the .REG file for the application and merge the registration file again, or you can add the key directly using the Registration Info Editor. </OL> <P>You should only use Visual Basic or an OLE utility called GUIDGEN.EXE to create class IDs. GUIDGEN.EXE is included in the directory of the VB CD. Class IDs are very large numbers that are unique among all the applications installed on your system. If two applications use the same class ID, OLE can't distinguish between the two applications, and errors occur. </BODY> </HTML>