Я встретил множество препятствий, но большинство вещей работало:
- перечислить устройства и файлы
- получить свойства файла
- переименовать файл
- создать папку
- copyDeviceFileToPc
- copyPcFileToDevice
Это мой код
Код: Выделить всё
typedef const wchar_t *string_t;
bool wpd::Device::deleteFile(string_t file_id)
{
PROPVARIANT file ={};
IPortableDevicePropVariantCollection *filesToDelete = newIPortableDevicePropVariantCollection(); // Calls CoCreateInstance
IPortableDeviceContent *devContentMgr;
file.vt = VT_LPWSTR;
file.pwszVal = (LPWSTR)file_id;
filesToDelete->Add(&file);
// IPortableDevice *dev initialized in constructor
dev->Content(&devContentMgr);
HRESULT hr = devContentMgr->Delete(PORTABLE_DEVICE_DELETE_NO_RECURSION,filesToDelete,NULL);
filesToDelete->Release();
devContentMgr->Release();
return SUCCEEDED(hr);
}
Подробнее здесь: https://stackoverflow.com/questions/629 ... -to-hang-h