NO

Author Topic: Using window dll  (Read 2782 times)

magic

  • Guest
Using window dll
« 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)

Code: [Select]
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;
}
« Last Edit: September 11, 2008, 04:35:22 PM by magic »

severach

  • Guest
Re: Using window dll
« Reply #1 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.

Code: [Select]
//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

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Using window dll
« Reply #2 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.
---
Stefan

Proud member of the UltraDefrag Development Team