public void SetupDiGetDeviceInstallParamsTest() { using var deviceInfoSet = SetupDiCreateDeviceInfoList((Guid *)null, IntPtr.Zero); SP_DEVINFO_DATA deviceInfoData = SP_DEVINFO_DATA.Create(); // If DeviceInstanceId is NULL or references a zero-length string, SetupDiOpenDeviceInfo adds a device information element // to the supplied device information set, if one does not already exist, for the root device in the device tree. string deviceId = null; if (!SetupDiOpenDeviceInfo(deviceInfoSet, deviceId, IntPtr.Zero, SetupDiOpenDeviceInfoFlags.None, ref deviceInfoData)) { throw new Win32Exception(); } SP_DEVINSTALL_PARAMS deviceInstallParams = SP_DEVINSTALL_PARAMS.Create(); if (!SetupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData, ref deviceInstallParams)) { throw new Win32Exception(); } deviceInfoData = SP_DEVINFO_DATA.Create(); Assert.False(SetupDiGetDeviceInstallParams(deviceInfoSet, deviceInfoData, ref deviceInstallParams)); }
public void SetupDiOpenDeviceInfoTest() { using var deviceInfoSet = SetupDiCreateDeviceInfoList((Guid *)null, IntPtr.Zero); SP_DEVINFO_DATA deviceInfoData = SP_DEVINFO_DATA.Create(); // If DeviceInstanceId is NULL or references a zero-length string, SetupDiOpenDeviceInfo adds a device information element // to the supplied device information set, if one does not already exist, for the root device in the device tree. string deviceId = null; Assert.True(SetupDiOpenDeviceInfo(deviceInfoSet, deviceId, IntPtr.Zero, SetupDiOpenDeviceInfoFlags.None, ref deviceInfoData)); }