2

This code check run application this param:

INT APIENTRY _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT iShow)
{

    char* szCmdLine = lpCmdLine;

...
}

Error this lines : error C2440: 'initializing' cannot convert from 'LPTSTR' to 'char *'

Mykola
  • 3,343
  • 6
  • 23
  • 39
Endy3k
  • 69
  • 2

1 Answers1

2

Its because LPTSTR could be LPSTR or LPWSTR considening project UNICODE settings. When unicode is enabled application use LPWSTR, if not LPSTR.

LPSTR is just an alias for char*. LPWSTR - wchar_t*. T in LPTSTR mean TCHAR type which defenition can be char or wchar_t whatever UNICODE or _UNICODE symbol is defined in your project.

LP means "long pointer", long is 32 bit memory address. STR - string.

So lets describe LPSTR - "long pointer to ANSI string"; LPWSTR - "long pointer to wide character string" and LPTSTR - "long pointer to TCHAR string".

To W or T letter can be added prefix C like LPCSTR, LPCTSTR, LPCWSTR wich means that these pointers are constant like const char* or const wchar_t*.

So your code must look like:

INT APIENTRY _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT iShow)
{

    TCHAR* szCmdLine = lpCmdLine;

...
}

or

INT APIENTRY _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT iShow)
{

    LPTSTR szCmdLine = lpCmdLine;

...
}
Mykola
  • 3,343
  • 6
  • 23
  • 39