Hi i’m using VS2010 and MBCS. Can anyone tell me how to convert an unsigned char to LPCSTR? Sorry i’m only new to c++…:) Thanks
This is the code it is failing on:
hr = MsiSetProperty(hInstall, "LOCKCODE", szLockCode);
ExitOnFailure(hr, "failed to set LOCKCODE");
szLockCode is the variable that needs to be converted.
An unsigned char array (
unsigned char szLockCode[10]for instance) is technically already an LPCSTR. If you’re using an array already then conversion is not the issue, if not, then you need an array. If you want a single character string, then you need an array of length 2. The character goes in the first position (szLockCode[0]) and the value 0 goes in the second position (szLockCode[1]).