Posted By

jwielandt on 11/24/10


Tagged

dll


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jwielandt


load library windows


 / Published in: C++
 

  1. #include <Windows.h>
  2.  
  3. //define a functor
  4. typedef void __stdcall (*F_functionName)(int arg1, int arg2);
  5.  
  6.  
  7. HANDLE handle = LoadLibrary("LibraryName.dll");
  8. if(handle == NULL) {
  9. //error
  10. }
  11.  
  12.  
  13. //assing value to funtor
  14. F_functionName functionName = (F_functionName ) GetProcAddress(handle, "FunctionName");
  15.  
  16. //use function
  17. functionName(1,2);
  18.  
  19.  
  20. //free library when nog longer needed
  21. FreeLibrary(handle);

Report this snippet  

You need to login to post a comment.