KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q137516: How to Register an MFC OLE Automation Server to Avoid Failure

Article: Q137516
Product(s): Microsoft C Compiler
Version(s): 
Operating System(s): 
Keyword(s): 
Last Modified: 05-FEB-2000

-------------------------------------------------------------------------------
The information in this article applies to:

- The AppWizard, included with:
   - Microsoft Visual C++, 32-bit Editions, versions 2.0, 2.1, 2.2 
-------------------------------------------------------------------------------

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.

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          :  
Technology        : kbVCsearch kbAudDeveloper kbAppWizard

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.