Microsoft KB Archive/137516

= How to Register an MFC OLE Automation Server to Avoid Failure =

Article ID: 137516

Article Last Modified on 10/24/2003

-

APPLIES TO

 The AppWizard, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 2.2 

-

<div class="notice_section">

This article was previously published under Q137516

<div class="summary_section">

SUMMARY
Creation of an OLE Object may fail if the registry file (.reg) generated by AppWizard is used to register the server for the object. This article explains how to avoid this failure.

<div class="moreinformation_section">

MORE INFORMATION
Registration of an MFC OLE Automation server typically occurs when running the server stand-alone for the first time. An alternate way of registering the server is to run the registration editor and merge the .reg file generated by AppWizard for the server's project. This method is necessary if the server is installed but not run before a client tries to create it.

It is necessary that the setup program that installs the server also replace any occurrence of the executable in the .reg file with the fully- qualified path and file name of the executable. When AppWizard creates the .reg file for the project, AppWizard does not know what the final path to the executable will be. Therefore, AppWizard cannot fill in the fully qualified path name for the server.

If the .reg file provided by the AppWizard is used as is to register the server for an object, OLE won't be able to find the server, creation of the object will fail, and OLE will return the error CO_E_SERVER_EXEC_FAILURE.

Sample Code
The following is an example of the \LocalServer key for the AutoClik, Step 1 sample as generated by AppWizard: HKEY_CLASSES_ROOT\CLSID\{2106E720-AEF8-101A- 9005-00DD0108D651}\LocalServer = AUTOCLIK.EXE After being setup correctly, the \LocalServer key in the .reg file may appear as follows: HKEY_CLASSES_ROOT\CLSID\{2106E720-AEF8-101A- 9005-00DD0108D651}\LocalServer = C:\MSVC20\SAMPLES\MFC \autoclik\step3\WinDebug\AUTOCLIK.EXE

Additional query words: kbinf 2.00 2.10 2.20 3.00 3.10 3.20

Keywords: KB137516

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.