cocus

c++ load vb6 dll

Dec 7th, 2011
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <stdio.h>
  4. #include <iostream.h>
  5. #include <windows.h>
  6.  
  7.  
  8. // Exported VB functions we'll be calling:
  9. typedef void (__stdcall * PFUNC)(void);
  10.  
  11. int main(int argc, char* argv[])
  12. {
  13.     HINSTANCE hMod = 0;
  14.     PFUNC pFunc = NULL;
  15.     char dummy;
  16.  
  17.     cout << "cargando lib \"exports.dll\"\n";
  18.    
  19.     // Load the VB DLL:
  20.     hMod = LoadLibrary(".\\exports.dll");
  21.     cout << "hMod=" << hMod << "\n";
  22.  
  23.     if (hMod)
  24.     {
  25.         // Call the export:
  26.         pFunc = (PFUNC)GetProcAddress(hMod, "ShowForm");
  27.         cout << "pFunc*=" << pFunc << "\n";
  28.  
  29.         if (pFunc)
  30.         {
  31.             //MessageBox(NULL, "Calling the ShowForm export...","Calling ShowForm",0);
  32.             cout << "llamando \"ShowForm\" de \"exports.dll\"\n";
  33.             pFunc();
  34.         } else
  35.             cout << "proc not found \"ShowForm\"\n";
  36.  
  37.         FreeLibrary (hMod);
  38.     } else
  39.         cout << "error cargando lib\n";
  40.  
  41.     cin >> dummy;
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment