Hello. This is a P/Invoke question which, quite frankly is doing my head in.
I need to get a string from a byte because calling the object.Tostring() methond on he variable doesn't yield the correct information.
given the following (which was extracted from p/invoke.net:
I need to retrieve the string returned in that variable but unfortunately the closest thing/way I know of doesn't work: string tmp = Marshal.PtrToStringAuto(ptrBuf) although this is the way it's used in the p/invoke.net example.
public static extern bool SetupDiGetDeviceRegistryProperty(IntPtr DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData,
uint Property, out uint PropertyRegDataType,
byte PropertyBuffer, uint PropertyBufferSize,
out uint RequiredSize);
result = SetupDiGetDeviceRegistryProperty(deviceInfoSet, ref tBuff, (uint)SPDRP.HARDWAREID, out RegType, null, 0, out RequiredSize);
ptrBuf = new byte[RequiredSize];
buffersize = RequiredSize;
result = SetupDiGetDeviceRegistryProperty(deviceInfoSet, ref tBuff, (uint)SPDRP.HARDWAREID, out RegType, ptrBuf, buffersize, out RequiredSize);
Can anyone put a sign post up pointing me in the right direction pls? At the moment I'm reading through several MarshalAs texts but to be honest for such a simple thing, I don't want to over-complicate the task at hand by getting into convoluted code(s).
Thank you very much.