PRB: ActiveDesktop Compilation Errors Under Visual C++ 6.0 MFC (196342)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Visual C++, 32-bit Professional Edition 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q196342

SYMPTOMS

Under Visual C++ 6.0 Microsoft Foundation Classes (MFC), compiling code related to the IActiveDesktop interface will fail with multiple errors, including an "undeclared identifier" for LPACTIVEDESKTOP.

Note that this occurs specifically when compiling an MFC program using Visual C++ 6.0. There is no report of the problem occurring in previous versions of MFC or in the general Visual C++ 6.0 case where C or C++ programs are being compiled.

CAUSE

When an MFC application includes the Stdafx.h header file, the file *\Vc98\Mfc\Include\Afxdisp.h is included by default. Within Afxdisp.h the file Shlobj.h (required for ActiveDesktop) is included. But at this point, Wininet.h has not been included, so certain portions of Shlobj.h are not correctly initialized for ActiveDesktop support.

The inclusion of Shlobj.h by Afxdisp.h also sets a variable preventing Shlobj.h from being included twice. Later, when an MFC application explicitly and correctly includes Wininet.h followed by Shlobj.h, the previously set variable prevents the second Shlobj.h inclusion and also prevents critical ActiveDesktop definitions, such as for LPACTIVEDESKTOP, from being made.

RESOLUTION

Add a #include for the Wininet.h header to the Stdafx.h precompiled header file, just above the Afxdisp.h include. Here's an example of Stdafx.h:
// stdafx.h : include file for standard system include files,

...

#include <wininet.h>
#include <afxdisp.h>        // MFC Automation classes

...

#endif //!defined(AFX_STDAFX_H__D5E466A9...
				
After correcting Stdafx.h, rebuild the entire project to ensure that the precompiled header is re-compiled.

Modification Type:MajorLast Reviewed:6/18/2001
Keywords:kbActiveDesktop kbprb KB196342