Re: command_line() help
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 16, 2001
- 439 views
----- Original Message ----- From: <euman at bellsouth.net> To: "EUforum" <EUforum at topica.com> Subject: Re: command_line() help > > I was under the assumption that lpzstr > was a 0-terminated string. An LPZSTR is a Long Pointer to a Zero-terminated String. That is, it contains a 32-bit address of the first byte in a #00 terminated array of bytes. > would someone explain what the "lpt" is? An LPTSTR is a Long Pointer to a Zero-terminated wide-character String. That is, it contains a 32-bit address of the first unsigned 16-bit number in a #0000 terminated array of unsigned 16-bit numbers. The definition here comes from the Windows SDK. typedef unsigned short WCHAR; // wc, 16-bit UNICODE character typedef WCHAR *LPWSTR; typedef LPWSTR LPTSTR; > and why is there a difference in the name? LPZSTR points to a set of bytes, and LPTSTR points to a set of 16-bit numbers. LPTSTR is used for unicode characters. When using the UTF-8 encoding scheme, the ASCII character set maps into the unicode characters set with the same bit patterns. Thus, you can use LPTSTR or LPZSTR if you are only dealing with ASCII characters, but you must use LPTSTR is you also have other unicode characters in the same string. If you read further into the SDK documentation on GetCommandLine() there is this statement: "The reason that main() and WinMain() cannot return Unicode strings is that argc, argv, and lpCmdLine use the LPSTR data type for parameters, not the LPTSTR data type. The GetCommandLine function can be used to access Unicode strings, because it uses the LPTSTR data type. " ----- cheers, Derek