public static string[] GetDevRegPropertyMultiStr( SetupApi.DeviceInfoSet devInfoSet, SetupApi.SP_DEVINFO_DATA devInfoData, SetupApi.SPDRP property) // Use this function for any 'Device Registry // Property' that returns 'REG_MULTI_SZ', // e.g. SPDRP_HARDWAREID { int propertyRegDataType; int requiredSize; // 'buffer' is 4KB but Unicode chars are 2 bytes, // hence 'buffer' can hold up to 2K chars const int BUFFER_SIZE = 4096; byte[] buffer = new byte[BUFFER_SIZE]; SetupApi.SetupDiGetDeviceRegistryProperty( devInfoSet.Get(), devInfoData, property, out propertyRegDataType, buffer, BUFFER_SIZE, out requiredSize ); return(Helpers.StringArrayFromMultiSz(buffer)); }
public static string GetDevRegPropertyStr( SetupApi.DeviceInfoSet devInfoSet, SetupApi.SP_DEVINFO_DATA devInfoData, SetupApi.SPDRP property) // Use this function for any 'Device Registry // Property' that returns a string, // e.g. SPDRP_CLASSGUID { int propertyRegDataType; int requiredSize; // 'buffer' is 1KB but Unicode chars are 2 bytes, // hence 'buffer' can hold up to 512 chars const int BUFFER_SIZE = 1024; byte[] buffer = new byte[BUFFER_SIZE]; SetupApi.SetupDiGetDeviceRegistryProperty( devInfoSet.Get(), devInfoData, property, out propertyRegDataType, buffer, BUFFER_SIZE, out requiredSize ); return(System.Text.Encoding.Unicode.GetString( buffer, 0, requiredSize )); }