|
From: <ren...@zk...> - 2007-09-14 13:21:14
|
Problem calling a dll together with MessageBox
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Hi
I am having a problem calling (or using) a DLL together with
the MessageBox API call. The problem goes away when I use
printf instead of MessageBox.
Here are the test files to reproduce it:
prog.c:
-------
#include <windows.h>
//#define WORKS
int main(int argc, char **argv, char **env) {
HANDLE dll =3D LoadLibraryEx("theDll.dll", 0, 0);
if (!dll) {
#ifdef WORKS
printf("Nope\n");
#else
MessageBox(0, "Nope", 0, 0);
#endif
}
else {
#ifdef WORKS
printf("Yepp\n");
#else
MessageBox(0, "Yepp", 0, 0);
#endif
}
}
dll.c
-----
#include <windows.h>
DllMain(HANDLE hModule,
DWORD fdwReason,
LPVOID lpvReserved)
{
MessageBox(0, "DllMain", "DllMain", 0);
printf("DllMain\n");
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
default:
break;
}
return TRUE;
}
---
I compile the files like so:
gcc -mdll -otheDll.dll dll.c
gcc -otheProg.exe prog.c
and execute then theProg.exe from cmd.
I am probably missing a flag such as -mwindows or so, but
including this flag didn't help either. Does someone have
a hint as to what I am doing wrong.
Thanks,
Ren=E9
___________________________________________________________________
Disclaimer:
Diese Mitteilung ist nur fuer die Empfaengerin / den Empfaenger bestimm=
t.
Fuer den Fall, dass sie von nichtberechtigten Personen empfangen wird,
bitten wir diese hoeflich, die Mitteilung an die ZKB zurueckzusenden un=
d
anschliessend die Mitteilung mit allen Anhaengen sowie allfaellige Kopi=
en
zu vernichten bzw. zu loeschen. Der Gebrauch der Information ist verbot=
en.
This message is intended only for the named recipient and may contain
confidential or privileged information.
If you have received it in error, please advise the sender by return e-=
mail
and delete this message and any attachments. Any unauthorised use or
dissemination of this information is strictly prohibited.=
|