• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

Installation Challenges with OCXs and DLLs

I have been handed an installation that does not work properly.  At the end of the install we attempt to register some in-house OCX's and DLL's.  They fail in the install, but if you reboot and then register they succeed.  Why?  knowing how to force a reboot out of installshield and automatically registering upon return would be sufficient, but I would appreciate any good reasons for the initial failure as well.  Thanks in advance.
  • 2
1 Solution
The reason probably is that you're also updating system DLLs (like e.g. the DAO Engine or an MFC DLL). As these DLLs are mostly in use, InstallShield places a '[rename]' section in wininit.ini (or uses 'MoveFileEx (..., MOVEFILE_DEAY_UNTIL_REBOOT,...);' on NT), which causes Windows to actually move the files before the system starts. To remedy this, place an entry like this in the registry:

function SetupRegistry()
STRING szKey, szValueName, szValue;
INT nSize, nType;



szKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
szValueName = "myocxreg";
szValue     = "regsvr32.exe /s myocx.ocx";
RegDBSetKeyValueEx ( szKey, szValueName, nType, szValue, nSize);

  return 0;

Feel free to ask if you need more information!
BigOneAuthor Commented:
Great answer, thanks for the help.  I am registering several OCXs and Dlls and they must be registered in the proper order.  Using your method they were called in the desired order, but can I rely on the order of execution following the order entered?  How does RunOnce work?  Any additional info would be appreciated.
Hmpf, MSDN Online is sooo *slow* at the moment that I hardly can provide links, and my local edition holds no information on the processing order - from my experience with the Registry APIs, the entries should be processed in alphabetical order (value name). If you don't want to rely on this, I'd suggest using a little (invisible) application that does the registration for you. Links will follow as soon as I get a response from the MS server ;-)

Here's the definition of these keys:

Knowledge Base
Definition of the RunOnce Keys in the Registry
Article ID: Q137367
Creation Date: 26-SEP-1995
Revision Date: 21-NOV-1996
The information in this article applies to:

Microsoft Windows 95


There are seven Run keys in the registry that cause programs to be run automatically:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ RunServices
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ RunServicesOnce
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ RunOnce\Setup


Keys 1-4 are run each time a new user logs in.

Keys 5-6 are run in the background when the logon dialog box first appears, or at this stage of the boot process if there is no logon. These keys are for background services such as remote registry service and are run only once per boot.

Key 7 is run as part of Setup's first-boot activities, or after you use the Add/Remove Programs Wizard.

Under each of these keys is a series of subkeys. The subkeys are used to allow multiple sub-entries to exist without overwriting one another.

The value for a subkey is a command line. By default, Run keys are ignored in Safe mode. For keys 3-4, the command line can be prefixed with an exclamation point to defer deletion of the subkey until after the command has been completed.

For keys 3, 4, and 6, the subkey is deleted before the command line is run unless overridden as noted above. As a result, if a RunOnce operation fails to run properly, the component that failed will not be asked to run again the next time you start the computer.

Key 7 is used only by Setup. This key displays the progress dialog box as the keys are run one at a time. For key 7, the name of the subkey is the name that is displayed in the dialog box.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now