Solved

fixing or working around a problem with MFC42d.dll

Posted on 2004-08-10
5
15,315 Views
Last Modified: 2013-11-20
Hello, I am trying to compile a WRAPI test program and am having MFC difficulties.

Background:  I am working in C++ .NET 2003 and the program instructions assume Studio 6.0.  Reading threads with other people having earlier compile difficulties over in the Wireless question area, I added the next two lines to stdafx.h

#include <afx.h>
#include <afxwin.h>

Without those, the next, essential line, explodes messily in bad syntax.

#include <ntddndis.h>

Those includes mean the test program, otherwise a console app, needs the appropriate dll.

When I build the program it compiles completely.  On running it tells me "the application has failed to start because MFC42D.DLL was not found.  Re-installing the applicaiton may fix the problem."

No biggie.  I copied MFC42D.dll to my source directory, rebuilt, and got:  "The application or DLL c:\<source>\MFC42D.DLL is not a valid Windows image.  Please check this against your installation diskette."

I don't know enough about MFC to do more then flail at a solution.  I'd appreciate advice on any of the following:

1)  An explanation of the above and how to fix it.

2)  A work around.  Then test program is a console app.  Does ntddndis.h needs MFC (I don't know)?  If not, how can I replace the afx.h & afxwin.h with anything?

3)  I've looked for MFC42D.DLL on my .NET install disks and on Microsoft support.  Where can I find a valid Windows image?

4)  Another way to solve this problem.

Thanks,

Rylen
0
Comment
Question by:rylen
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:SteH
Comment Utility
Do you want to use MFC in your project?
Or would a line like
#include <windows.h>
be sufficient. It might be necessary to do some definitions before that line.
0
 
LVL 1

Author Comment

by:rylen
Comment Utility
Thanks SteH.  This may be a start but unfortunately does not solve the problem yet.  This is currently an MFC because a bit of previous solution I followed led me to insert afx.h and afxwin.h.

I dropped afx.h and afxwin.h for windows.h and have tried to build with "Use of MFC" set to both "Standard Windows Library" and "MFC in static library."  In both cases my results depended on if I'd removed MFC42D.dll and .lib from the source directory.  If I remove them, I get:  "The application has failed to start ..." as above.  If I put them back, I get "The application or DLL .. is not a vaild Windows image ..." as above.
0
 
LVL 13

Accepted Solution

by:
SteH earned 200 total points
Comment Utility
If you have a console app that uses MFC you need to include afx.h and afxwin.h! Only in a purist approach you would use Win APIs for a console app if you use windows at all. If I use the app wizard to create a console app that support MFC I get the following includes in stdafx.h:

#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers

#include <afx.h>
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdtctl.h>            // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>                  // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <iostream>  ///< This is support for console operations.

Another thing might be some defines which are not uptodate any more:
See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcconmfcvisualcversionnumbers.asp
for versions of MFC shipped with different versions of VC++ and
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/versions.asp
for common controls.

From those sources you should use (automatically?) mfc71.dll and not mfc42.dll (the extra d after the number is only for debug version of those DLLs).

0
 
LVL 13

Expert Comment

by:SteH
Comment Utility
0
 
LVL 1

Author Comment

by:rylen
Comment Utility
Thanks.  From this I've gotten a extremly important bit of information.  VC++ 7 is not compatible w/ DLLs from VC++ 6.  I'll be using the links you gave me (and reading and asking questions) to recompile the WRAPI source code to work in .NET.

Rylen
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now