title: Dynamically load a function from a DLL
body: <p>I'm having a little look at .dll files, I understand their usage and I'm trying to understand how to use them.</p>
  
  <p>I have created a .dll file that contains a function that returns an integer named funci()</p>
  
  <p>using this code, I (think) I've imported the .dll file into the project(there's no complaints):</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;iostream&gt;
  
  int main() {
    HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\Documents and Settings\\User\\Desktop  \\fgfdg\\dgdg\\test.dll");
  
    if (hGetProcIDDLL == NULL) {
      std::cout &lt;&lt; "cannot locate the .dll file" &lt;&lt; std::endl;
    } else {
      std::cout &lt;&lt; "it has been called" &lt;&lt; std::endl;
      return -1;
    }
  
    int a = funci();
  
    return a;
  }
  
  # funci function 
  
  int funci() {
    return 40;
  }
  </code></pre>
  
  <p>However when I try to compile this .cpp file that I think has imported the .dll I have the following error: </p>
  
  <pre><code>C:\Documents and Settings\User\Desktop\fgfdg\onemore.cpp||In function 'int main()':|
  C:\Documents and Settings\User\Desktop\fgfdg\onemore.cpp|16|error: 'funci' was not     declared in this scope|
  ||=== Build finished: 1 errors, 0 warnings ===|
  </code></pre>
  
  <p>I know a .dll is different from a header file so I know I can't import a function like this but it's the best I could come up with to show that I've tried.</p>
  
  <p>My question is, how can I use the <code>hGetProcIDDLL</code> pointer to access the function within the .dll. </p>
  
  <p>I hope this question makes sense and I'm not barking up some wrong tree yet again.</p>