0
#include <Windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    messagebox(NULL, L"1st WIN32 API !!!",L"note",MB_OK);
    return 0;
}

Here is my question: Why should I use hInstance, hPrevInstance, lpCmdLine, nCmdShow? In place of using that I used

int WINAPI WinMain(HINSTANCE first, HINSTANCE second, LPSTR third, int fourth) and program works.

Wooble
  • 87,717
  • 12
  • 108
  • 131
techno
  • 101
  • 1
  • 1
  • 8

2 Answers2

2

In most programming languages, you can give variables and parameters whatever names you like. The compiler/interpreter and any API's you use typically don't care. The names given in documentation are usually just examples or suggestions. What matters is the type of variable, e.g. int or HINSTANCE.

In practice though, you should usually give variables and parameters meaningful names. That can make it much easier for you (or someone else) to work on your code in future, as the name can be a reminder about what it's for.

Peter Bloomfield
  • 5,578
  • 26
  • 37
1

why should I use hInstance, hPrevInstance, lpCmdLine, nCmdShow

Because it's very useful to give variables meaningful names. The types and order of the parameters for a function declaration or definition matter, not their names.

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272