Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Basic question about Win32 API programming in C

  1. Dec 20, 2006 #1
    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.
     
  2. jcsd
  3. Dec 20, 2006 #2

    verty

    User Avatar
    Homework Helper

  4. Dec 20, 2006 #3
    It has nothing to do with C, it is simply a calling convention for Win32 programs to refer to the program entry point.
     
  5. Dec 20, 2006 #4

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    WINAPI is a macro; if you were feeling industrious, you could go searching through the header files, looking for where it is defined.
     
  6. Dec 21, 2006 #5
    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..
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Basic question about Win32 API programming in C
Loading...