lilrangerabn
April 9th, 2010, 07:17 PM
I have a method where I am reading a REG_SZ from a registry key. I know that the value of buff is exactly what is in the REG_SZ key, however when converting it to a System::String it gets extra spaces added in between the correct values.
String^ flags;
char buff[255];
dwType = REG_SZ;
dwSize = sizeof(buff);
memset(buff, 0, sizeof(buff));
if (::RegQueryValueEx( keyHandle, L"regvalue", NULL, &dwType,
(BYTE*) buff, &dwSize) == ERROR_SUCCESS){
char * temp = &buff[0];
flags = gcnew String(temp, 0, sizeof(buff));
//simple test to ensure what we are seeing
for (int i=0; i < sizeof (buff); i++ ){
printf(&buff[i]);
}
Console::WriteLine("\nCurrent REG_SZ value is: \n\t " + flags);
}
Sample output from the printf:
BOB, BOB
Sample output from the WriteLine:
B O B , B O B
Can anyone explain why and advise me how to correct it so that it does not add the spaces?
String^ flags;
char buff[255];
dwType = REG_SZ;
dwSize = sizeof(buff);
memset(buff, 0, sizeof(buff));
if (::RegQueryValueEx( keyHandle, L"regvalue", NULL, &dwType,
(BYTE*) buff, &dwSize) == ERROR_SUCCESS){
char * temp = &buff[0];
flags = gcnew String(temp, 0, sizeof(buff));
//simple test to ensure what we are seeing
for (int i=0; i < sizeof (buff); i++ ){
printf(&buff[i]);
}
Console::WriteLine("\nCurrent REG_SZ value is: \n\t " + flags);
}
Sample output from the printf:
BOB, BOB
Sample output from the WriteLine:
B O B , B O B
Can anyone explain why and advise me how to correct it so that it does not add the spaces?