News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Using window dll

Started by magic, September 11, 2008, 04:23:43 PM

Previous topic - Next topic

magic

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;
}

severach

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

Stefan Pendl

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.
---
Stefan

Proud member of the UltraDefrag Development Team