Hey, I am trying to use exported dll functions like in the following working code:
How do I use a function which needs arguments (unlike SHExitWindowsEx)? And where would I find the arguments it needs?Code:#include <windows.h> #include <iostream.h> #include <stdio.h> #include <conio.h> #define MAXMODULE 50 typedef void (WINAPI*cfunc)(); cfunc DoSomething; void main() { HINSTANCE hLib=LoadLibrary("SHELL32.dll"); if(hLib==NULL) { cout << "Unable to load library!" << endl; getch(); //lame pause return; } char mod[MAXMODULE]; GetModuleFileName((HMODULE)hLib, (LPTSTR)mod, MAXMODULE); cout << "Library loaded: " << mod << endl; DoSomething=(cfunc)GetProcAddress((HMODULE)hLib, "SHExitWindowsEx"); if((DoSomething==NULL)) { cout << "Unable to load function(s)." << endl; FreeLibrary((HMODULE)hLib); return; } DoSomething(); FreeLibrary((HMODULE)hLib); getch(); //lame pause }




Reply With Quote