title: can't get address of the dll function with GetProcAddress
body: <p>I created a dll with VS C++ (of course as a dll project) with the following code of the header file:</p>
  <pre><code>#pragma once
  #include &lt;iostream&gt;
  #include &quot;..\..\profiles/ProfileInterface.h&quot;
  
  using namespace std;
  
  extern &quot;C&quot; __declspec(dllexport) class CExportCoordinator: public CProfileInterface
  {
  public:
      CExportCoordinator(void);
      virtual ~CExportCoordinator(void);
      
      CProfileInterface* Create();
      void Initialize();
      void Start();   
  };
  </code></pre>
  <p>Here is .cpp file of the dll:</p>
  <pre><code>#include &quot;StdAfx.h&quot;
  #include &quot;ExportCoordinator.h&quot;
  
  CExportCoordinator::CExportCoordinator(void)
  {
  }
  
  CExportCoordinator::~CExportCoordinator(void)
  {
  }
  
  CProfileInterface* CExportCoordinator::Create(){
      
      cout &lt;&lt; &quot;ExportCoordinator3 created...&quot; &lt;&lt; endl;
      return new CExportCoordinator();
  }
  
  void CExportCoordinator::Initialize(){
  
          cout &lt;&lt; &quot;ExportCoordinator3 initialized...&quot; &lt;&lt; endl;
  }
  
  void CExportCoordinator::Start(){
      
      cout &lt;&lt; &quot;ExportCoordinator3 started...&quot; &lt;&lt; endl;
  }
  </code></pre>
  <p>I exported the whole class <code>CExportCoordinator</code> because I need to use all three methods it offers. Following is the code from the main application loading the, above given, dll on the fly.</p>
  <pre><code>    typedef CProfileInterface* (WINAPI*Create)();
      
      int _tmain(int argc, _TCHAR* argv[])
  
  {    
      HMODULE hLib = LoadLibrary(name);
      
  
      if(hLib==NULL) {
          cout &lt;&lt; &quot;Unable to load library!&quot; &lt;&lt; endl;         
          return NULL;
      }
      char mod[MAXMODULE];
      
      GetModuleFileName(hLib, (LPTSTR)mod, MAXMODULE);
      cout &lt;&lt; &quot;Library loaded: &quot; &lt;&lt; mod &lt;&lt; endl;   
          
      Create procAdd = (Create) GetProcAddress(hLib,&quot;Create&quot;);
          
      if (!procAdd){
          cout &lt;&lt; &quot;function pointer not loaded&quot;;
      }
      return;
  }
  </code></pre>
  <p>On the output I get that correct library is loaded, but that function pointer <code>procAdd</code> is NULL. I thought it had something to do with name mangling and added <code>extern &quot;C&quot;</code> when exporting the class in header of dll, but nothing changed. Btw, I used <a href="http://www.nirsoft.net/utils/dll_export_viewer.html" rel="nofollow noreferrer">dll export viewer</a> for viewing the exported functions of the class, and the whole class is exported correctly.
  Any help?</p>
  <p><strong>UPDATE</strong><br />
  there is an error in the header file of dll. I shouldn't be using <code>extern &quot;C&quot; __declspec(dllexport)</code> before class because then class won't be exported at all. If I use <code>class __declspec(dllexport) CExportCoordinator</code> then the class is exported correctly, but anyway I can't get the address of the function other than NULL.</p>