Pelles C forum

C language => Beginner questions => Topic started by: magic on September 11, 2008, 04:23:43 PM

Title: Using window dll
Post by: magic on September 11, 2008, 04:23:43 PM
Hi, can someone write me a code to use window MessageBoxA()
Just write a code display "Hi there" using window dll MessageBoxA()
I really confuse how to import dll staticlly.

Thanks

this is my code(not working)

int __cdecl MessageBoxA(int a,char *s1,char *s2,int b);

#include <stdio.h>

/* entry point */
int main(void)
{
MessageBoxA(0,"Hi there","Hi there",0);
    return 0;
}
Title: Re: Using window dll
Post by: severach on September 11, 2008, 10:04:47 PM
MessageBoxA is __stdcall not __cdecl but you don't need to know that. Include the right header file and library and the import is done for you.

//int __cdecl MessageBoxA(int a,char *s1,char *s2,int b);

#include <windows.h>
#include <stdio.h>

/* entry point */
int main(void)
{
MessageBoxA(0,"Hi there","Hi there",0);
    return 0;
}


Project Options Linker Library and Object Files: Add USER32.LIB
Title: Re: Using window dll
Post by: Stefan Pendl on September 12, 2008, 09:10:41 AM
You do not need to use MessageBoxA, MessageBox will do, the header file will decide which version to use, ANSI or UNICODE, based on the setting of a variable.
Check the Windows header for the variables name.