winmain example

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Hello, World!", "My First GUI Program", MB_OK);
    return 0;
}
  • #include <windows.h>: This line includes the Windows header file, which provides access to various functions and definitions for Windows-specific programming.
  • int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow): This is the entry point for a Windows GUI application. It is similar to the main function in a console application, but specifically for Windows GUI programs.
  • MessageBox(NULL, "Hello, World!", "My First GUI Program", MB_OK): This line creates a message box with the text "Hello, World!" and the title "My First GUI Program". The MB_OK parameter specifies that the message box should display an OK button.
  • return 0;: This statement exits the WinMain function and returns 0 to indicate successful program execution.