Advertisement
Guest User

Michael

a guest
Feb 17th, 2010
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement