BYTE[ ] to LPWSTR conversion
Unicode is defined.
I am trying to read IP Address from the registry which is stored as a string value by using RegQueryValueEx() method. This returns the string value of the IPAddress in the registry as BYTE[256]. I need to convert this BYTE[256] = regvalue to LPWSTR regvalue. Pl. help me.
Many thanks in advance.
skp.
[347 byte] By [
skp] at [2007-11-17 11:49:30]

# 2 Re: BYTE[ ] to LPWSTR conversion
Hi,
What is RegQueryValueEx giving actually? Its a char* or wchar*? If you get wchar* then you can typecast it.. and use. If not use mbtowc to convert char* to wchar*.
Hope this helps...
Let me know if got helped. If you got helped pls rate!!!
John
# 4 Re: BYTE[ ] to LPWSTR conversion
The RegQueryValueEx is giving a BYTE array. I can type cast it to char* when Unicode is not defined, but when Unicode is defined type casting it to char* doesnot work. I cannot use mbtocw if I donot have a char*.
So, Either I need to convert Byte keyValue[256] to LPWSTR or I need to convert Byte keyValue[256] to char* so that I can use A2W or MultiBytetoWideChar() macro to covert it LPWSTR.
skp at 2007-11-10 8:09:50 >

# 5 Re: BYTE[ ] to LPWSTR conversion
I was trying to automate some procedure and therefore there is no scope for manual changes.
Is there any other solution that you can provide.
Thanks
skp at 2007-11-10 8:10:50 >

# 6 Re: BYTE[ ] to LPWSTR conversion
Hi,
BYTE* (BYTE array) is nothing but unsigned char*. So you can typecast it to char*. No problem. So you can use mbtowc in the following way...
WCHAR wcharArray[256];
mbtowc(wcharArray, (char*)byteArray, strlen(byteArray));
Good luck!
Let me know if got helped. If you got helped pls rate!!!
John