OLE and the Registry

an article added by: Dessue Mathenes at 12132007


In: Categories » » Windows registry » OLE and the Registry

Wow, now we're back to the registry. That was a lot of stuff to cover, just to get a handle of the basics of OLE. As I've mentioned, OLE works extensively with the registry. When an application registers itself with OLE as a potential server application, this registration process consists of adding a number of entries into the registry. For OLE applications, such as ActiveX controls, these entries are relatively simple and easy to follow. More complex OLE applications-take Microsoft Word as an example-have hundreds of entries in the registry and are typically difficult to understand. Let's look at a simple OLE control-the ActiveX control called Calendar Control 10.0, which is an application available from Microsoft (as part of Office XP) that allows users to insert a calendar into their document. Yes, Calendar Control 10.0 is embeddable into a Word document (you can also embed it into many other types of documents). This usage, which is typical, is very useful-think of how many times you needed to include a calendar in a document. Check out Figure 6.4 to see Word and Calendar Control 10.0 working together. In the document that I used for this figure, I actually used the date that I was writing this tutorial.

Size and Placement...

Calendar Control 10.0 allows for easy resizing. However, some versions of ActiveX controls don't work as well when embedded into Word. They may create an underlying window that makes sizing the control's main window difficult. Because of this, the embedded control tends to resize its display in unexpected ways. This is not acceptable behavior, I might add. If you embed an object that is difficult to resize, try this: First resize the offending control to make it smaller, and then quickly-before Word can resize it-click the underlying base window. This locks the base window so you can resize the control's window as appropriate. A simple double-click anywhere inside the base window restores the normal display. Microsoft Calendar Control 10.0 allows a lot of interaction with other documents and applications-you can set the month and year as desired using the drop-down list boxes. Nevertheless, why would you, a user, want other interaction? Easy! One classic example is to embed Calendar Control into a Web page, a document whose application is the Web browser. Another example is to embed Calendar Control into an e-mail message. Ding! Did the light go off? E-mail everyone on your team and include in the message the details of a virtual meeting with the calendar showing the appropriate date. You can modify the properties of embedded objects. There are usually two ways to set the object's properties. The first is to use the programmatic interface (geeky-see Figure 6.5). You can also use the object's Object Properties dialog box (see Figure 6.6). The programmatic interface allows access to all possible properties, while the Object Properties dialog box allows quick and simple modification of selected object properties.

So, we have a Microsoft Calendar Control 10.0 OLE server application implemented as an ActiveX control. Let's look at the registry entries for Calendar Control. First are the entries in HKEY_LOCAL_MACHINE\Software\Classes\CLSID. These entries define much of the OLE interface:

{8E27C92B-1264-101C-8A2F-040224009C02}]
   @="Calendar Control 10.0"

The lines above are the hive (HKEY_LOCAL_MACHINE), key (Software), and subkeys (Classes\CLSID), followed by any values that these keys might contain. A value in the form of @=data denotes the default value entry found in every registry key and subkey.

Note The Windows XP CLSID is identical the Windows NT 2000 CLSID. Surprised? Don't be, as the CLSID comes from the application, not the operating system. Also, Calendar Control 10.0 probably has the same CLSID as Calendar Control 9.0. The first subkey contains the CLSID for the Calendar Control 10.0 server. This CLSID happens to be 8E27C92B-1264-101C-8A2F-040224009C02, although other versions of Calendar Control (if they were substantially different) might have different CLSIDs. The default data variable contains a string describing the program. Notice that this string is also found in the second section of the registry, HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSCAL.Calendar.7, described next.

{8E27C92B-1264-101C-8A2F-040224009C02}\CLSID
   @="8E27C92B-1264-101C-8A2F-040224009C02"

Windows uses the AuxUserType subkey for short, people-readable names for the application. Menus, both regular and pop-up, use these short names. Microsoft recommends that the names in AuxUserType be limited to not more than 15 characters. The entry, InprocHandler32, tells the system what in-process handler will be used.

{8E27C92B-1264-101C-8A2F-040224009C02}\InprocServer32
   @="C:\Program Files\Microsoft Office\Office10\MSCAL.OCX"

Many applications use InprocServer.dll as their in-process handler, although this is not a requirement. Another commonly used in-process handler is MAPI32.DLL, which is used by many mail-enabled objects: Intended for use with Windows XP, the Insertable entry indicates to the system that the application is listed in the insert list of the Insert New Object dialog box:

{8E27C92B-1264-101C-8A2F-040224009C02}\Insertable
   @=""

The next entry contains the application's fully qualified path and executable filename. This string is not a REG_EXPAND_SZ, so don't use substitution variables:

{8E27C92B-1264-101C-8A2F-040224009C02}\MiscStatus
   @="131473"

Note In MiscStatus, combine values using binary or bitwise addition; the easiest way to do a bitwise is to simply add the values. For example, an application with the flags: "The object sets the client site first" (131072), "Activate object when it is visible" (256) "The Object is inside out" (128)" The object can't link inside" (16), and "When resizing, the object is recomposed" (1) would store a value of (131072 + 256 + 128 + 16 + 1) = 131473 in MiscStatus, which is exactly the value that is in our Calendar Control object's MiscStatus. In some entries, the Printable subkey denotes an OLE object that will support the IPrint method (Printable is not found in all objects-only those that are printable using the IPrint method):

{8E27C92B-1264-101C-8A2F-040224009C02}\Printable
   @=""

For an object that may be inserted, there must be an associated ProgID value (ProgID is shorthand for "programmatic identifier"). This value consists of a short name, a type, and a numeric value (the numeric value is often a version number):

{8E27C92B-1264-101C-8A2F-040224009C02}\ProgID
   @="MSCAL.Calendar.7"

A registry section is created with this name (see the next entry), where more registry values will be stored for this object:

{8E27C92B-1264-101C-8A2F-040224009C02}\Verb
 @=""

Verbs indicate types of action that the object may take. Always numbered consecutively in the registry, there are three components to verb entries, as shown here:

{8E27C92B-1264-101C-8A2F-040224009C02}\Verb\0
   @="&Edit,0,2"

This sample verb, Edit, shows three things. First, the text used in the menu, &Edit. The & indicates that the letter following it will be underscored and used as a hotkey value.

There is a second section of the registry for the Calendar Control 10.0 OLE object. This section, in HKEY_LOCAL_MACHINE\Software\Classes, is called MSCAL.Calendar.7. In the MSCAL.Calendar subkey, there are two possible value entries. One is shown below:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSCAL.Calendar]
   @="Calendar Control 10.0"

The first value entry is the default value (@=) that contains the name ("Calendar Control 10.0") used in the insert list of the Insert Object dialog box. A second value that some objects may use is EditFlags, which contains the edit flags, expressed as hex values. The CLSID subkey contains the object's CLSID:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSCAL.Calendar\CLSID]
   @="{8E27C92B-1264-101C-8A2F-040224009C02}"

When present, the next subkey (which works with the Microsoft OLE DocObject technology) may contain information about the capabilities of the OLE object:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSCAL.Calendar.7\DocObject]
   @="0"

Intended for use in Windows 2000 and Windows XP, the following entry indicates to the system that the application should be listed in the insert list of the Insert New Object dialog box:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSCAL.Calendar\Insertable]
   @=""

The protocol subkey is used for compatibility with OLE 1 container (client) applications:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSCAL.Calendar\protocol]
   @=""

There is one subkey in protocol, called StdFileEditing. Within StdFileEditing, there are a number of items, as shown here:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.6\protocol\StdFileEditin
   g]
   @=""

The default entry in StdFileEditing is an empty string.

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.6\protocol\StdFileEditin
   g\server]
   @="C:\\PROGRA~1\\MICROS~2\\winword.exe"

The first subkey in StdFileEditing is the server subkey. Inside server is the default string containing the fully qualified name of the server executable file. (The Calendar control doesn't have this entry, so I've shown the entry for Word.) Because this string is REG_SZ, do not use any substitutable variables, such as %SystemRoot%, in it.

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSCAL.Calendar\protocol\StdFileEditing
   \verb]
   @=""

The next subkey in StdFileEditing is verb. Inside verb are one or more numbered subkeys; numbers begin with 0 and should be consecutive. Each verb that the OLE application uses in a menu will be included, as shown here:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSCAL.Calendar\protocol\StdFileEditing
   \verb\0]
 @="&Edit"

This verb is the Edit menu selection. The text used in the menu is &Edit. The & indicates that the letter following it will be underscored and used as a hotkey value. Finally, a version-independent ProgID is created. Even when the control is updated, this entry won't change:

   HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{8E27C92B-1264-101C-8A2F-
   040224009C02}\
   VersionIndependentProgId
 @="MSCAL.Calendar"

Like ProgID, this identifies the program, without any version references.

legal notice

Our website is not responsible for the information contained by this article. Web-articles is a free articles resource.
Suggestion: If you need fresh, daily updated content for your website, feel free to use our service. Click here for more information.

Useful tools and features

Link to this article from your page    Send this article to you or to a friend
If you like this article (tutorial), please link to it from your web page using the information above.

related articles

1. You can choose from several methods to back up your registry
Backup Techniques You can choose from several methods to back up your registry, and you can store your backed-up version on a variety of media. Whether you use the Windows XP Backup program or similar utilities, DOS commands, or the Registry Editor, you should first understand what type of file systems your computer network uses. Windows XP supports two different file systems. The first file system, called FAT (File Allocation Table), is identical to the file system used with both DOS and Windows 95/98/Me. The...

2. Once you install a second copy of Windows XP
Customizing the Boot Menu Once you install a second copy of Windows XP, your boot menu will list both copies of Windows XP. This can be confusing since the descriptions will be almost identical. There is a solution: the boot menu can be customized. The boot drive's root directory contains a file called boot.ini. This file includes the boot options for each copy of Windows XP that is installed. Edit boot.ini by following these steps: 1. Open the Windows XP Control Panel in Classic view. 2. Open System Proper...

3. A registry that has been backed up using copy or xcopy is restored
Recovering a Copied Registry A registry that has been backed up using copy or xcopy is restored in the opposite manner from which it was backed up. For example, if you have the NTFS file system, then you have to restart the system using your backup copy of Windows XP. FAT and NTFS When restoring a registry on a FAT-based file system running Windows XP, it's necessary to boot DOS, Windows 95/98/Me, or a second copy of Windows XP. If you have a dual-boot installed (either DOS or Windows 95/98/M...

4. The Windows XP Recovery Console is a tool that allows recovery
The Recovery Console The Windows XP Recovery Console is a tool that allows recovery from a number of failures. Previously, all you could do was boot another copy of Windows XP and hack your way around, replacing files, even registry components, in the blind hope that you would somehow fix the problem. With Windows XP, you have two tools to use: the Recovery Console and the Safe Mode feature. The Recovery Console is a powerful, simple (no, that's not an oxymoron!) feature that is supplied with Windows XP, but it i...

5. What the registry is and the terminology used for its various components
Anatomy of the Registry–The Blood, Gore, and Guts Overview In tutorial 1, we talked a little about what the registry is and the terminology used for its various components. In tutorial 2, we covered backing up and restoring the registry. In this tutorial, we will get into more of the details of what actually is in the registry. If you're only interested in how to use (or recover) the registry, but not what the registry is, it's possible to skip this tutorial. However, if you're unsure about this,...

6. The current control set is copied into the Last Known Good control set
When Is the Current Control Set the Last Known Good Control Set? At some point in the boot process, the current control set is copied into the Last Known Good control set. In Windows XP, the process of replacing the Last Known Good control set is done after the initial logon is performed. This allows the system to catch any problems related to the logon process. HKEY_USERS: Settings for Users Let's take a closer look at SIDs. No, despite what you may think, SID is not the kid down the street;...

7. Windows XP uses only one registry editor
Registry Tools and Tips–Getting the Work Done Overview Windows XP uses only one registry editor. Gone are the separate RegEdit and RegEdt32 editors that existed in Windows 2000. No matter which command you enter in Windows XP, RegEdt32 or RegEdit, the same program (RegEdit, which is called the Registry Editor) will run. Windows XP also has a utility called REG that is included as part of the system installation no more needing to install a separate Resource Kit. This tool is run at the comman...

8. The Registry Editor allows you to quickly create
Creating, Renaming, and Deleting Entries The Registry Editor allows you to quickly create, delete, or rename an entry. Entries may consist of keys, subkeys, or value entries. Creating a New Key You can quickly create a new key by following these steps: 1. Select the hive or key in which the new key is to be created. Either right-click the object or select Edit → New, and then select the type of object to create. 2. The Registry Editor creates the new subkey, giving it a default name of N...

9. The Registry Editor may be used from the command line
Using the Registry Editor from the Command Line The Registry Editor may be used from the command line, without user interaction. The commands that the Registry Editor uses include those described below. (Note that not all commands may be available under all operating systems.) • To import a registry file into the Registry Editor: REGEDIT [/L:system] [/R:user] filename1 • To create a registry object from a file: REGEDIT [/L:system] [/R:user] /C filename2...

10. Several tips come to mind when using the Registry Editor
Tips for Registry Editor Users Several tips come to mind when using the Registry Editor: • First, when saving a hive using Save Key (under the Registry menu), make absolutely sure that the filename saved to is descriptive enough to enable the successful restoration of the hive at a later time. The Registry Editor doesn't check whether a hive being restored is the same hive as the one being replaced. • Second, as with the Registry Editor, be aware that printing can create reports of incredible s...