• Advertisement

Archived

This topic is now archived and is closed to further replies.

WinMain

This topic is 6458 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. When creating a plain-vanilla window using: int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd ) { ... } what does the WINAPI part of the declaration mean? Is it a return type just like ''int''? Thanks. |-|A[k3R$Z R \/\/|-|AT |V|Ak3 t|-|3 \/\/0R|_D g0 R0|_||\|D!!

Share this post


Link to post
Share on other sites
Advertisement
WINAPI tells the compiler and linker that that function is loaded from a dll somewhere else.

Share this post


Link to post
Share on other sites
WINAPI is just a type declaration. PASCAL i believe for Intel 80x86 processors. the use of WINAPI instead of PASCAL is simply for source code portability issues.


typedef PASCAL WINAPI;

Share this post


Link to post
Share on other sites
WINAPI is the calling convention which is the same as PASCAL.
It states the method in asm that should be created by the compiler for this function to return data. Usually WINAPI will used with .dll''s and Windows Shell.

typedef WINAPI FAR PASCAL.. ?? i think

Share this post


Link to post
Share on other sites
Actually, just take a look at windef.h for your answers.

Depdning on the platform WINAPI is defined as various things. When _MAC is defined WINAPI is defined as CDECL which is defined as __cdecl. Otherwise it is defined as __stdcall. __stdcall has the following charateristics:

Argument-passing order: Right to left.

Argument-passing convention: By value, unless a pointer or reference type is passed.

Stack-maintenance responsibility: Called function pops its own arguments from the stack.

Name-decoration convention: An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12

Case-translation convention: None
[end]

I'm pretty sure unless noted otherwise functions by default use the __cdecl calling convention which has the following characteristics:

Argument-passing order: Right to left

Stack-maintenance responsibility: Calling function pops the arguments from the stack

Name-decoration convention: Underscore character (_) is prefixed to names

Case-translation convention: No case translation performed
[end]

When PASCAL is used it is defined as __stdcall anyway. __pascal calling convention is obsolete.

Edited by - Sheltem on June 21, 2000 1:17:41 AM

Share this post


Link to post
Share on other sites
Thanks for the explanations. I''ll probably be posting plenty of questions in the near future ''cause I''m now just learning this stuff.

|-|A[k3R$Z R \/\/|-|AT |V|Ak3 t|-|3 \/\/0R|_D g0 R0|_||\|D!!

Share this post


Link to post
Share on other sites

  • Advertisement