chrome/browser/system_monitor/portable_device_watcher_win.cc
// Gets a list of removable storage object identifiers present in |device|.
// On success, returns true and fills in |storage_object_ids|.
Gets a list of removable storage object identifiers present in |device|.
On success, returns true and fills in |storage_object_ids|.
Gets a list of removable storage object identifiers present in |device| . On success returns true and fills in |storage_object_ids| .
bool GetRemovableStorageObjectIds(
    IPortableDevice* device,
    PortableDeviceWatcherWin::StorageObjectIDs* storage_object_ids) {
  DCHECK(device);
  DCHECK(storage_object_ids);
  base::win::ScopedComPtr<IPortableDeviceCapabilities> capabilities;
  HRESULT hr = device->Capabilities(capabilities.Receive());
  if (FAILED(hr)) {
    DPLOG(ERROR) << "Failed to get IPortableDeviceCapabilities interface";
    return false;
  }
  base::win::ScopedComPtr<IPortableDevicePropVariantCollection> storage_ids;
  hr = capabilities->GetFunctionalObjects(WPD_FUNCTIONAL_CATEGORY_STORAGE,
                                          storage_ids.Receive());
  if (FAILED(hr)) {
    DPLOG(ERROR) << "Failed to get IPortableDevicePropVariantCollection";
    return false;
  }
  DWORD num_storage_obj_ids = 0;
  hr = storage_ids->GetCount(&num_storage_obj_ids);
  if (FAILED(hr))
    return false;
  for (DWORD index = 0; index < num_storage_obj_ids; ++index) {
    PROPVARIANT object_id = {0};
    PropVariantInit(&object_id);
    hr = storage_ids->GetAt(index, &object_id);
    if (SUCCEEDED(hr) && (object_id.pwszVal != NULL) &&
        (object_id.vt == VT_LPWSTR)) {
      storage_object_ids->push_back(object_id.pwszVal);
    }
    PropVariantClear(&object_id);
  }
  return true;
}
bool GetRemovableStorageObjectIds ( IPortableDevice * device , PortableDeviceWatcherWin :: StorageObjectIDs * storage_object_ids ) { DCHECK ( device ) ; DCHECK ( storage_object_ids ) ; base :: win :: ScopedComPtr < IPortableDeviceCapabilities > capabilities ; HRESULT hr = device -> Capabilities ( capabilities . Receive ( ) ) ; if ( FAILED ( hr ) ) { DPLOG ( ERROR ) << " " ; return false ; } base :: win :: ScopedComPtr < IPortableDevicePropVariantCollection > storage_ids ; hr = capabilities -> GetFunctionalObjects ( WPD_FUNCTIONAL_CATEGORY_STORAGE , storage_ids . Receive ( ) ) ; if ( FAILED ( hr ) ) { DPLOG ( ERROR ) << " " ; return false ; } DWORD num_storage_obj_ids = 0 ; hr = storage_ids -> GetCount ( & num_storage_obj_ids ) ; if ( FAILED ( hr ) ) return false ; for ( DWORD index = 0 ; index < num_storage_obj_ids ; ++ index ) { PROPVARIANT object_id = { 0 } ; PropVariantInit ( & object_id ) ; hr = storage_ids -> GetAt ( index , & object_id ) ; if ( SUCCEEDED ( hr ) && ( object_id . pwszVal != NULL ) && ( object_id . vt == VT_LPWSTR ) ) { storage_object_ids -> push_back ( object_id . pwszVal ) ; } PropVariantClear ( & object_id ) ; } return true ; }
Gets a list of removable storage object identifiers present in |device|.
Gets a list of removable storage object identifiers present in |device| .