Beispiel #1
0
        std::vector<Property> get_all_properties(const wchar_t * i_query)
        {
            std::vector<Property> props;
            auto                  query_results = execute_query(i_query);
            for (const auto & result : query_results)
            {
                TESTITY_COM_CALL(result->BeginEnumeration(0));

                for (;;)
                {
                    CComBSTR    prop_name;
                    CComVariant prop_value;
                    if (result->Next(0, &prop_name, &prop_value, NULL, NULL) != ERROR_SUCCESS)
                    {
                        break;
                    }
                    prop_value.ChangeType(VT_BSTR);

                    Property prop;
                    prop.m_name  = ConvertBSTRToMBS(prop_name);
                    prop.m_value = ConvertBSTRToMBS(prop_value.bstrVal);
                    props.push_back(std::move(prop));
                }

                TESTITY_COM_CALL(result->EndEnumeration());
            }
            return std::move(props);
        }
Beispiel #2
0
        std::vector<std::string> get_properties(
          const wchar_t * i_query, const std::vector<const wchar_t *> & i_property_names)
        {
            auto                     query_results = execute_query(i_query);
            std::vector<std::string> value_strs;
            value_strs.resize(i_property_names.size());
            for (size_t property_index = 0; property_index < i_property_names.size();
                 property_index++)
            {
                for (const auto & result : query_results)
                {
                    auto & value_str = value_strs[property_index];
                    if (value_str.length() > 0)
                    {
                        value_str += ", ";
                    }

                    CComVariant value;
                    CIMTYPE     value_type;
                    TESTITY_COM_CALL(
                      result->Get(i_property_names[property_index], 0, &value, &value_type, NULL));
                    value.ChangeType(VT_BSTR);
                    value_str += ConvertBSTRToMBS(value.bstrVal);
                }
            }
            return value_strs;
        }
void Audio::LogDeviceInformation(IEnumMoniker *pEnum)
{
	logger.addline("Starting to record audio or video input devices.", info);
	IMoniker *pMoniker = NULL;

	while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
	{
		logger.addline("Have found a new device", success);
		IPropertyBag *pPropBag;
		HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
		if (FAILED(hr))
		{
			pMoniker->Release();
			continue;
		}

		VARIANT var;
		VariantInit(&var);

		// Get description or friendly name.
		hr = pPropBag->Read(L"Description", &var, 0);
		if (FAILED(hr))
		{
			hr = pPropBag->Read(L"FriendlyName", &var, 0);
		}
		if (SUCCEEDED(hr))
		{
			//printf("%S\n", var.bstrVal);
			logger.addline("Below is the device name.", debug);
			logger.addline(ConvertBSTRToMBS(var.bstrVal), debug);
			VariantClear(&var);
		}

		hr = pPropBag->Write(L"FriendlyName", &var);

		// WaveInID applies only to audio capture devices.
		hr = pPropBag->Read(L"WaveInID", &var, 0);
		if (SUCCEEDED(hr))
		{
			//printf("WaveIn ID: %d\n", var.lVal);
			logger.addline("Below is the WaveIn ID.", debug);
			logger.addline("BLANK FOR NOW! FIX ME LATER", debug);
			VariantClear(&var);
		}

		hr = pPropBag->Read(L"DevicePath", &var, 0);
		if (SUCCEEDED(hr))
		{
			// The device path is not intended for display.
			printf("Device path: %S\n", var.bstrVal);
			logger.addline("Below is the device path.", debug);
			//logger.addline(ConvertBSTRToMBS(var.bstrVal), success);
			VariantClear(&var);
		}

		pPropBag->Release();
		pMoniker->Release();
	}
}