News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Difference between LPWSTR and LPCTSTR?

Started by georgek01, November 16, 2005, 09:14:27 AM

Previous topic - Next topic

georgek01

Hi there,

When passing parameters to WIN32 API functions, what's the difference between LPWSTR and LPCTSTR? Should I be converting my buffer to unicode before passing as LPWSTR? If so, what will this conversion look like?


Regards,
George
What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)

sluggy

Yes, LPWSTR is a pointer to a unicode string. You may not have to convert your string, most API functions have an ANSI equivalent (typically the type will then be LPSTR). And there is an API function to convert strings between ANSI and Unicode, but i can't remember what it is called. 
Deep down, the difference between some of those many "pointer to string" types is nothing - it all comes down to typecasting ultimately for code safety - you could just as easily pass a void* and the API function will still work on it if the compiler let you compile it that way.

georgek01

Thank you!

I'll use MultiByteToWideChar to make the conversion.
What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)