如何在项目中定位(和删除)依赖于MFC的代码?

Nav*_*Nav 5 migration mfc visual-studio-2010 visual-c++

我有一个使用MFC和COM的大型遗留项目。想法是将其迁移到Linux(winelib对此不起作用),我需要确定使用MFC的代码部分。奇怪的是,该解决方案包含两个从CWinApp继承并实例化的DLL项目。此外,在这些DLL中我看不到CWinApp的用途,因为实际的GUI代码在单独的非dll项目中。

两个问题:
1.是否有任何工具可以帮助我找到MFC特定的代码以便将其删除?已经看到了Qt选项
2.为什么在完全不执行任何GUI工作的DLL项目中实例化CWinApp(如下所示)?它用于消息传递吗?我没有看到任何这样的语法。删除CWinApp实例化会导致另一个项目的指针未初始化。奇怪的!

DLL项目的代码之一如下所示:

#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();
}
Run Code Online (Sandbox Code Playgroud)

l33*_*33t 5

  1. 在MFC项目设置中,更改Use of MFC使用标准Windows库。然后从中删除所有以'afx'开头的内容StdAfx.h。编译错误将带您进入MFC的所有特定部分!
  2. CWinApp是否可以让您的MFC可执行文件正确使用DLL中的任何MFC代码。该框架将通过此对象初始化您的DLL。对于非MFC DLL,您只需使用DllMain

关于COM没有MFC,我将首先进行以​​下搜索:atl com codeproject