Basic question about Win32 API programming in C

  • Thread starter chingkui
  • Start date
  • #1
193
1

Main Question or Discussion Point

I have a very basic question about Win32 API programming in C, I am trying to understand the following syntax:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
return 0;
}

While "int" specifies the return type of WinMain, what does "WINAPI" in between "int" and "WinMain" do? Is this syntax a part of C standard?

Thanks.
 

Answers and Replies

  • #3
1,997
5
I have a very basic question about Win32 API programming in C, I am trying to understand the following syntax:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
return 0;
}

While "int" specifies the return type of WinMain, what does "WINAPI" in between "int" and "WinMain" do? Is this syntax a part of C standard?

Thanks.
It has nothing to do with C, it is simply a calling convention for Win32 programs to refer to the program entry point.
 
  • #4
Hurkyl
Staff Emeritus
Science Advisor
Gold Member
14,916
19
WINAPI is a macro; if you were feeling industrious, you could go searching through the header files, looking for where it is defined.
 
  • #5
157
1
It has nothing to do with C, it is simply a calling convention for Win32 programs to refer to the program entry point.
This is not strictly true. WINAPI is just a define for a calling convention, the fact that the entry point uses this calling convention is not really important. You can use WINAPI for any function or function pointer. It think it is also possible to have a Win32 entry-point which does not use this calling convention, but I am not 100% sure, will have to test that when I get home today..
 

Related Threads on Basic question about Win32 API programming in C

  • Last Post
Replies
1
Views
920
Replies
3
Views
2K
  • Last Post
Replies
1
Views
2K
Replies
2
Views
8K
  • Last Post
Replies
1
Views
6K
Replies
4
Views
3K
Replies
5
Views
2K
Replies
1
Views
559
Top