| 385 | } |
| 386 | |
| 387 | bool VariantUtilities::GetVariantObjectPropertyValue(IDispatch* variant_object_dispatch, |
| 388 | std::wstring property_name, |
| 389 | VARIANT* property_value) { |
| 390 | LPOLESTR property_name_pointer = reinterpret_cast<LPOLESTR>(const_cast<wchar_t*>(property_name.data())); |
| 391 | DISPID dispid_property; |
| 392 | HRESULT hr = variant_object_dispatch->GetIDsOfNames(IID_NULL, |
| 393 | &property_name_pointer, |
| 394 | 1, |
| 395 | LOCALE_USER_DEFAULT, |
| 396 | &dispid_property); |
| 397 | if (FAILED(hr)) { |
| 398 | // Only log failures to find dispid to debug level, not warn level. |
| 399 | // Querying for the existence of a property is a normal thing to |
| 400 | // want to accomplish. |
| 401 | LOGHR(DEBUG, hr) << "Unable to get dispatch ID (dispid) for property " |
| 402 | << StringUtilities::ToString(property_name); |
| 403 | return false; |
| 404 | } |
| 405 | |
| 406 | // get the value of eval result |
| 407 | DISPPARAMS no_args_dispatch_parameters = { 0 }; |
| 408 | hr = variant_object_dispatch->Invoke(dispid_property, |
| 409 | IID_NULL, |
| 410 | LOCALE_USER_DEFAULT, |
| 411 | DISPATCH_PROPERTYGET, |
| 412 | &no_args_dispatch_parameters, |
| 413 | property_value, |
| 414 | NULL, |
| 415 | NULL); |
| 416 | if (FAILED(hr)) { |
| 417 | LOGHR(WARN, hr) << "Unable to get result for property " |
| 418 | << StringUtilities::ToString(property_name); |
| 419 | return false; |
| 420 | } |
| 421 | return true; |
| 422 | } |
| 423 | |
| 424 | std::wstring VariantUtilities::GetVariantObjectTypeName(VARIANT value) { |
| 425 | std::wstring name = L""; |