#include//Function for loading DLL HMODULE Load_DLL(char* DLL){ HANDLE Proc; HMODULE hDLL; hDLL = LoadLibraryA(DLL); if(hDLL == NULL){ //Fail FreeLibrary(hDLL); } else{ //Sucess } FreeLibrary(hDLL); return hDLL ; } FARPROC Get_ProcA(char* DLL , char* FUNC){ HMODULE hDLL = Load_DLL(DLL); FARPROC Myproc = GetProcAddress(hDLL,FUNC); if (Myproc == NULL) FreeLibrary(hDLL); return Myproc; } //Define the function to load typedef int(__stdcall *msgbox)(HWND, LPCSTR, LPCSTR, UINT); int main() { //Call you function msgbox Me = msgbox(Get_ProcA("User32", "MessageBoxA")); //TestIt Me(0,"TEST","Success",0); return 0; }
jeudi 10 janvier 2013
Call you function dynamically in c++
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire