Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to locate (& remove) MFC dependent code in a project?

I've got a huge legacy project which uses MFC and COM. The idea being to migrate it to Linux (winelib doesn't work for this), I need to identify the portions of the code that use MFC. Strange thing is that the solution contains two DLL projects which inherit from CWinApp and instantiate it. Besides, I don't see the purpose of CWinApp in these DLL's because the actual GUI code is in a separate non-dll project.

Two questions:
1. Is there any tool which can help me locate the MFC specific code so that I can remove it? Already saw the Qt option.
2. Why is CWinApp instantiated (as below) in a DLL project which isn't doing any GUI work at all? Is it used for message passing? I don't see any such syntax though. Removing the CWinApp instantiation results in a pointer of another project not being initialized. Weird!

One of the DLL project's code goes like this:

#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "dlldatax.h"
//removed some project-specific includes for posting on SO

#ifdef _MERGE_PROXYSTUB
extern "C" HINSTANCE hProxyDll;
#endif

CComModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_MyManager, CMyManager)
//removed some other similar lines as the line above
END_OBJECT_MAP()

// Component Category Helper Functions
static HRESULT CreateComponentCategory( CATID catid, WCHAR* catDescription );
static HRESULT UnRegisterCategory( CATID catid );

class CMyClassWrapperApp : public CWinApp
{
public:
    public:
    virtual BOOL InitInstance();
    virtual int ExitInstance();
    DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(CMyClassWrapperApp, CWinApp)
END_MESSAGE_MAP()

CMyClassWrapperApp theApp;

BOOL CMyClassWrapperApp::InitInstance()
{
#ifdef _MERGE_PROXYSTUB
    hProxyDll = m_hInstance;
#endif
    _Module.Init(ObjectMap, m_hInstance, &LIBID_MyClassWrapperLib);
    return CWinApp::InitInstance();
}

int CMyClassWrapperApp::ExitInstance()
{
    _Module.Term();
    return CWinApp::ExitInstance();
}
like image 689
Nav Avatar asked Sep 04 '12 11:09

Nav


People also ask

Can I track a phone with just the number?

It is not possible to track someone's location just by cell phone number. You also need to use monitoring software for this purpose. The best way to find someone's location is using a cell phone tracking software or app.

How do you track someones location on Iphone?

Open the Find My app and select the People tab. Under People, choose the name of your friend who is sharing their location with you. Choose Directions to open Maps and then follow the directions to arrive at your friend's location.


1 Answers

  1. In your MFC project settings, change to Use of MFC to Use Standard Windows Libraries. Then remove all includes starting with 'afx' from your StdAfx.h. The compilation errors will guide you to all MFC specific parts!
  2. CWinApp is there to allow your MFC executable to correctly use any MFC code in your DLL. The framework will initialize your DLL through this object. For non-MFC DLLs you would just use DllMain.

Regarding COM and no MFC, I would start by googling this: atl com codeproject

like image 125
l33t Avatar answered Oct 11 '22 21:10

l33t