The correct way to convert int to LPCWSTR (Win32)

I am trying to learn basic Win32 programming and have run into a frustrating problem. I want to convert a variable (name it NumClicks) and display it as an application name (as part of a string). From what I saw, switching from int + some block of text to char * is problematic because converting it to the required final data type (LPCWSTR) is more complicated than straightforward casting.

Any ideas or links?

+3
source share
4 answers

use wsprintf
It allows you to compose a line in the same way as printf allows you to print a line of text.

+5
source

_itow _s

, INT LPWSTR (, ), StringCchPrintfW.

+3

, , LPCWSTR:


int f =55;  
wchar_t buffer[10];
_itow_s (f, buffer, 10);
func_using_lpcwstr_as_parameter(buffer);

0

instead of using wsprintf, I would use sprinf (buf, "% S", "plain old line");

-2
source

All Articles