S A string. This sequence is interpreted as type LPSTR when the calling application uses the #define UNICODE compile flag and as type LPWSTR otherwise.
However if I change the %s in the code below to %S,
Read the reference again -- if UNICODE is not defined then the type is LPWSTR, a wide character string so ordinary character string may appear as sequence of unprintable wide characters.
tkorrovi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's OK it seems that wsprintf cause the conversion with S (whatever it is) but there is no implicit conversion back to ordinary string. Also it's likely that LPSTR is interpreted as wide character string when UNICODE is defined though I never used unicode.
tkorrovi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
According to the Win32 Programmers Reference:
S A string. This sequence is interpreted as type LPSTR when the calling application uses the #define UNICODE compile flag and as type LPWSTR otherwise.
However if I change the %s in the code below to %S,
wsprintf(Buffer, "Save changes to %s", szFileTitle);
temp = MessageBox(hwnd, Buffer, TEXT("Text"), MB_YESNOCANCEL | MB_ICONEXCLAMATION);
I get the output:
Save changes to ????
The UNICODE flag is not defined in my program.
Any ideas why this is so?
Derek
Read the reference again -- if UNICODE is not defined then the type is LPWSTR, a wide character string so ordinary character string may appear as sequence of unprintable wide characters.
tkorrovi
Thanks tkorrovi, you're right. My mistake.
Derek
It's OK it seems that wsprintf cause the conversion with S (whatever it is) but there is no implicit conversion back to ordinary string. Also it's likely that LPSTR is interpreted as wide character string when UNICODE is defined though I never used unicode.
tkorrovi
Oh no, now I was wrong, it causes conversion of wide characters to sequence of ordinary characters whatever it means.
tkorrovi