The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: georgek01 on November 16, 2005, 09:14:27 AM

Title: Difference between LPWSTR and LPCTSTR?
Post by: georgek01 on November 16, 2005, 09:14:27 AM
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
Title: Re: Difference between LPWSTR and LPCTSTR?
Post by: sluggy on November 16, 2005, 12:11:05 PM
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.
Title: Re: Difference between LPWSTR and LPCTSTR?
Post by: georgek01 on November 17, 2005, 09:24:13 AM
Thank you!

I'll use MultiByteToWideChar to make the conversion.