Regarding string conversion
-
Hi all, I want to convert char* to unsigned short* string. How would i accomplish it?? Please give me some hint to make it work. it would be a great help to me. Thanks
Search terms to look for: USES_CONVERSION A2T A2W MultiByteToWideChar Iain.
-
Search terms to look for: USES_CONVERSION A2T A2W MultiByteToWideChar Iain.
char *subKey = GetLocalMachineName(); int nSize1 = MultiByteToWideChar(CP_ACP, 0, subKey, -1, NULL, 0); LPWSTR wSubKey = new WCHAR[nSize1]; MultiByteToWideChar(CP_ACP, 0, subKey, -1, wSubKey, nSize1); I have used above code. In above code function GetLocalMachineName() returns char * string which works correctly as i have debug it. what is the mistake in above code.. Please help me. Thanks
-
char *subKey = GetLocalMachineName(); int nSize1 = MultiByteToWideChar(CP_ACP, 0, subKey, -1, NULL, 0); LPWSTR wSubKey = new WCHAR[nSize1]; MultiByteToWideChar(CP_ACP, 0, subKey, -1, wSubKey, nSize1); I have used above code. In above code function GetLocalMachineName() returns char * string which works correctly as i have debug it. what is the mistake in above code.. Please help me. Thanks
I really suggest you read this article[^]. You will learn everything you need to handle the problem (and even much more).
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
char *subKey = GetLocalMachineName(); int nSize1 = MultiByteToWideChar(CP_ACP, 0, subKey, -1, NULL, 0); LPWSTR wSubKey = new WCHAR[nSize1]; MultiByteToWideChar(CP_ACP, 0, subKey, -1, wSubKey, nSize1); I have used above code. In above code function GetLocalMachineName() returns char * string which works correctly as i have debug it. what is the mistake in above code.. Please help me. Thanks
Your code works fine for me. Are you sure subKey points to a NULL-terminated string? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Your code works fine for me. Are you sure subKey points to a NULL-terminated string? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: