You receive an "E_INVALIDARG (0x80070057 or 'The parameter is incorrect')" error message from the CoCreateInstance function in Visual C++ on a computer that is running Windows 95 (183214)



The information in this article applies to:

  • The Microsoft Active Template Library (ATL) 2.0, when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 4.2b
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 4.2b
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • The Microsoft Active Template Library (ATL) 2.1, when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 4.2b
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 4.2b
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
    • Microsoft Visual C++ .NET (2002)
    • Microsoft Visual C++ .NET (2003)
  • The Microsoft Active Template Library (ATL) 3.0, when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 4.2b
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 4.2b
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q183214

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 later, Windows 95 with DCOM for Windows 95 installed, Windows 98, and Windows Millennium Edition (Me). 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:

STATUS

This behavior is by design.

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


Modification Type:MajorLast Reviewed:6/2/2005
Keywords:kbfunctions kbtshoot kbArchitecture kbBug kbCtrl kbDebug kberrmsg kbprb KB183214 kbAudDeveloper