Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Michael

By: a guest on Feb 17th, 2010  |  syntax: C++  |  size: 0.63 KB  |  views: 109  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Code for loading in the DLL
  2.  
  3. //Function pointer for the DLL function
  4. typedef Output  (WINAPI *AIFunc)(Input, float);
  5.  
  6. //Struct that I store the dll info into
  7. struct AiInfo
  8. {
  9.         AIFunc function;
  10.         HINSTANCE hInstLibrary;
  11. };
  12.  
  13. AiInfo SomeMethod(char * filename)
  14. {
  15.         AIFunc _AIFunc;
  16.         AiInfo info;
  17.         info.hInstLibrary = LoadLibrary(filename);
  18.         DWORD error = GetLastError();
  19.  
  20.         if (info.hInstLibrary)
  21.         {
  22.            _AIFunc = (AIFunc)GetProcAddress(info.hInstLibrary, aiFunc);
  23.  
  24.            if (_AIFunc)
  25.            {
  26.                   info.function = _AIFunc;
  27.                   return;
  28.            }
  29.         }
  30.         else
  31.         {
  32.            std::cout << "DLL Failed To Load!" << std::endl;
  33.         }
  34.         return info;
  35. }