bool DeviceDiscoveryImp::DiscoverDevices()

in library/src/DeviceDiscoveryImp.cpp [27:60]


bool DeviceDiscoveryImp::DiscoverDevices(DeviceFilter filter, bool includeIntegrated, bool includeDetachable)
{
	// Make sure WinRT is initialised for the calling thread
	Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
	
	try
	{
		// If this is the first time we're performing device discovery then create our helper objects
		if (!this->HaveDevices())
		{
			this->enumeration = std::make_unique<AdapterEnumeration>();
			this->wmi = std::make_unique<WmiQuery>();
		}
		
		// Enumerate the DirectX adapters that meet the supplied filtering criteria
		this->enumeration->EnumerateAdapters(filter, includeIntegrated, includeDetachable);
		
		// Retrieve the PnP device details from WMI for each of the enumerated adapters
		this->devices = this->wmi->GetDevicesForAdapters(this->enumeration->GetUniqueAdapters());
		
		// Retrieve the driver details from the registry for each of the devices
		for (auto& device : this->devices) {
			RegistryQuery::FillDriverDetails(device);
		}
		
		RETURN_SUCCESS(true);
	}
	catch (const DeviceDiscoveryError& err) {
		RETURN_ERROR(false, err.Pretty());
	}
	catch (const std::runtime_error& err) {
		RETURN_ERROR(false, winrt::to_hstring(err.what()));
	}
}