PRB: E_INVALIDARG Error from CoCreateInstance()

ID: Q183214


The information in this article applies to:
  • The Microsoft Active Template Library (ATL), versions 2.0, 2.1, 3.0, used with:
    • Microsoft Visual C++, 32-bit Editions, versions 4.2b, 5.0, 6.0


SYMPTOMS

Under Windows 95, you might get the following error returned from the CoCreateInstance() function:


   E_INVALIDARG (0x80070057 or "The parameter is incorrect") 


CAUSE

Your project might have the following macro:


   #define _WIN32_WINNT 0x0400 


By default, ATL projects contain this macro in StdAfx.h. In ObjBase.h, the CLSCTX_ALL and CLSCTX_SERVER flags are defined to include the CLSCTX_REMOTE_SERVER flag if the preprocessor symbol, _WIN32_WINNT, is defined to be greater than or equal to 0x0400 (_WIN32_WINNT >= 0x400).

CLSCTX_REMOTE_SERVER is only valid on Windows NT 4.0 or greater or Windows 95 with DCOM for Windows 95 installed. If you call CoCreateInstance() on Windows 95 (without DCOM for Windows 95) with a flag that includes CLSCTX_REMOTE_SERVER, it returns an E_INVALIDARG error.


RESOLUTION

Remove the following from StdAfx.h:


   #define _WIN32_WINNT 0x0400 


Or, you can install DCOM for Windows 95, which comes with an updated Ole32.dll. This version recognizes the CLSCTX_REMOTE_SERVER flag. You can download DCOM for Windows 95 from the following Web location:
http://www.microsoft.com/com/dcom/dcom1_2/dcom1_2.asp


STATUS

This behavior is by design.

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Samson Tanrena, Microsoft Corporation.

Additional query words: CreateInstance [ASCII 150]2147942487

Keywords : kberrmsg kbATL200 kbATL210 kbCOMt kbCtrl kbDebug kbVC420 kbVC500 kbVC600 kbWinOS95 kbATL300 kbGrpMFCATL kbArchitecture
Version : WINDOWS:2.0,2.1,3.0
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: November 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.