How to find (and remove) MFC-specific code in a project?

I have a huge project that uses MFC and COM. The idea of ​​switching to Linux (winelib does not work for this), I need to identify parts of the code that use MFC. The strange thing is that the solution contains two DLL projects that inherit from CWinApp and create it. In addition, I do not see the purpose of CWinApp in this DLL, because the actual GUI code is in a separate project other than the dll.

Two questions:
1. Is there any tool that can help me find a specific MFC code so that I can delete it? Already seen the Qt parameter.
2. Why is CWinApp created (as shown below) in a DLL project that does not work with the GUI at all? Is it used to send messages? However, I do not see such a syntax. Removing an instance of CWinApp results in a different project that is not initializing. Weird!

One of the projects of the DLL project is as follows:

#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(); } 
+4
source share
1 answer
  • In the settings of the MFC project, change to Use of MFC to Use Standard Windows Libraries . Then delete everything starting with 'afx' from your StdAfx.h . Compilation errors will help you all parts of MFC!
  • CWinApp so that your MFC executable correctly uses any MFC code in your DLL. The structure will initialize your DLL through this object. For a non-MFC DLL, you simply use DllMain .

As for COM and not MFC, I would start with a search query: atl com codeproject

+3
source

Source: https://habr.com/ru/post/1432255/


All Articles