Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124

Creating Your First Windows App in C++: A Simple Message Box
#include <windows.h>
int WINAPI wWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PWSTR lpCmdLine,
int nCmdShow
) {
MessageBoxW(
nullptr,
L"Hello World",
L"My Message Box",
MB_OK | MB_ICONINFORMATION
);
return 0;
}

#include <windows.h>This is the core Windows header file.
It pulls in the entire Win32 API, which gives you access to thousands of Windows functions such as:
MessageBoxCreateProcessRegOpenKeyExCreateFile, and so on.You must include this header in any Windows desktop (Win32) program.
int WINAPI wWinMain(...)This is your program’s entry point — the function that Windows calls when your app starts.
It’s like main() in a console program, but for GUI apps.
Let’s break down its parts:
int WINAPI wWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PWSTR lpCmdLine,
int nCmdShow
WINAPI__stdcall) used by Windows.HINSTANCE hInstanceHINSTANCE hPrevInstancePWSTR lpCmdLineLPWSTR = wchar_t*).argv in console programs, but as a single wide-character string.int nCmdShowShowWindow() when you create your own window — not used here.MessageBoxW(...)This is a Win32 API call that displays a simple message box dialog.
MessageBoxW(
nullptr,
L"Hello World",
L"My Message Box",
MB_OK | MB_ICONINFORMATION
);
| Parameter | Meaning |
|---|---|
nullptr | The parent window handle. nullptr = no parent, standalone box. |
L"Hello World" | The message shown inside the box. The L means it’s a wide (Unicode) string. |
L"My Message Box" | The title of the window. |
| `MB_OK | MB_ICONINFORMATION` |
💡 You can combine different flags, for example:
MB_YESNO | MB_ICONQUESTIONMB_OKCANCEL | MB_ICONERRORreturn 0;Returns 0 to Windows — which means “program exited successfully.”
wWinMain.MessageBoxW, which tells Windows to create and show a dialog box.That’s the simplest possible Windows GUI program — one API call, one message box.