OLE and the Registry

an article added by: Dessue Mathenes at 12132007


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

French Spanish Portuguese Italian German Japanese Chinese Korean Russian Arabic

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 disclaimer

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.

related articles

1. A value may contain one or in some instances more than one data item
Data Values A value may contain one or, in some instances, more than one data item. The only type of multiple-item value entry that the registry editor can handle is REG_MULTI_SZ, which may contain zero, one, or more strings. Data is stored in a number of different formats. Generally the system uses only a few simple formats, while applications, drivers, and so forth may use more complex types defined for a specific purpose. For example, REG_RESOURCE_LIST is a complex registry type used primarily by drive...

2. The registry has always been the one part of Windows that virtually
Preventing Disaster! Overview Preventing disaster is an important thing to do. No one wants a system failure or to have to reinstall Windows XP. Not the least of your problems will be the issues with product authorization, in that Windows XP, when reinstalled, must be reauthorized! You are reading this tutorial for your own particular reason. Perhaps, as I am recommending, you are here because you want to do everything possible to prevent a disaster with your Windows XP installation. Or maybe you re...

3. 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...

4. 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...

5. 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...

6. 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...

7. 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,...

8. 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;...