title: DLL using MFC without CWinApp?
body: <p>I've recently came across a DLL (<a href="https://github.com/nickorr/BaseElements-Plugin/tree/1.2a1" rel="nofollow">github</a>) that uses MFC dialogs (it imports <code>"afxdlg.h"</code> and calls <code>CFileDialog</code>, for example) and appears to statically link to MFC, but doesn't have a class based on <code>CWinApp</code>. I'm somewhat confused: is it a MFC DLL or not? How come it doesn't have <code>CWinApp</code>?</p>
  
  <p><strong>Rephrased:</strong> In a Win32 DLL I use some MFC classes (e.g. I include <code>"afxdlgs.h"</code> and use <code>CFileDialog</code>) and link MFC statically. There's no <code>DllMain</code>. Will the final DLL have <code>DllMain</code> from Win32 or from MFC?</p>
  
  <p>If it picks the MFC version, then another question: What is the simplest way to make a Win32 DLL with <code>DllMain</code> (no threads) to use MFC <code>DllMain</code>? Is the following correct?</p>
  
  <pre><code>#include "afx.h" /* correct? */
  
  class MyDll: public CWinApp
  {
  public:
      /* do I need constructor and destructor here? */
      virtual BOOL InitInstance();
      virtual BOOL ExitInstance();
  } theDll;
  
  BOOL
  MyDLL::InitInstance()
  {
      CWinApp::InitInstance();
      /* code from old DllMain, DLL_PROCESS_ATTACH. 
         For hInst use theDll.m_hInstance */
      return TRUE;
  }
  
  BOOL
  MyDLL::ExitInstance()
  {
      /* code from old DllMain, DLL_PROCESS_DETACH */
      return CWinApp::ExitInstance();
  }
  </code></pre>