I have a bit of a weird problem. I have a form with a Label in it for outputting text at certain points in the program instead of console output. Given the following code:
result = SetupDiGetDeviceRegistryProperty(deviceInfoSet, ref tBuff,
(uint)SPDRP.DEVICEDESC,
out RegType, ptrBuf,
buffersize, out RequiredSize);
if (!result)
{
errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
statusLabel.Text += "\nSetupDiGetDeviceRegistryProperty failed because "
+ errorMessage.ToString();
}
else
{
statusLabel.Text += "\nPtr buffer length is: " + ptrBuf.Length.ToString();
sw.WriteLine(tCode.GetString(ptrBuf) );
sw.WriteLine("\n");
// This is the only encoding that will give any legible output.
// Others only show the first character "U"
string tmp = tCode.GetString(ptrBuf) + "\n";
statusLabel.Text += "\nDevice is: " + tmp + ".\n";
}
I get just the one hardware ID output on the label. This piece of code is at the end of my loop. at 1st this made me think that my loop was some how hanging, but when I decided to direct output to a file I get almost what I want and the output outside the loop. Can anyone tell me what's going on here? All I want is to get the string representing the hardware ID from the []byte (ptrBuf). Can some explain what's going on here, please? My working environment is MSVstudio 2008 express. In windows 7.
Thanks