Hi guys I'm experimenting with DLL's and loading them. I've got a simple program that loads a DLL, and I've created a DLL that calls a function that displays a MessageBox.
The problem is when I launch my loader program, the MessageBox is displayed twice... I'm only calling LoadLibrary() once, so how can it be displayed twice?!
Any help would be greatly appreciated.
Here's the loader:
Code:
#include <iostream>
#include <Windows.h>
int main() {
HMODULE hDll = LoadLibrary("messageboxdll.dll");
if (!hDll) {
printf("Could not load DLL.\n");
return 1;
}
CloseHandle(hDll);
}
Here's the DLL:
Code:
#include <windows.h>
__declspec (dllexport) void Alert(void);
void Alert(void) {
MessageBox(NULL, "Successfully loaded!", "Loaded", MB_OK);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
Alert();
return TRUE;
}
I'm using Visual Studio 08.