我正在开发资源管理器挂钩,用于通过 MTP 协议监视便携式设备的数据。我从接口 IPortableDeviceContent 中连接了 Delete() 函数。这个函数给了我需要删除的文件对象 ID 的列表。我想在这里知道发送删除请求的文件的名称是什么。如果我可以从收到的文件对象中获取文件名,那么它将解决我的问题。
请让我知道是否有人对此有任何解决方案。
HookDelete()
是挂钩的功能IPortableDeviceContent::Delete()
。以下是上述问题的答案。以为它没有给我完整的路径,它至少给出了一个文件名。
HRESULT STDMETHODCALLTYPE PortableDeviceInternalHook::HookDelete(
IPortableDeviceContent *pTHIS,
const DWORD dwOptions,
IPortableDevicePropVariantCollection *pObjectIDs,
IPortableDevicePropVariantCollection **ppResults)
{
DWORD count;
if(S_OK == pObjectIDs->GetCount(&count))
{
HRESULT result = S_FALSE;
bool blockOperation;
CComPtr<IPortableDeviceProperties> spProperties;
result = pTHIS->Properties(&spProperties);
if(S_OK == result)
{
for (unsigned int i = 0; i < count; i++)
{
HRESULT propertyValueResult;
PROPVARIANT propertyValue = {0};
propertyValueResult = pObjectIDs->GetAt(i, &propertyValue);
CComPtr<IPortableDeviceValues> spDeviceValues;
result = S_FALSE;
if(S_OK == propertyValueResult)
{
result = spProperties->GetValues(propertyValue.pwszVal, NULL, &spDeviceValues);
PropVariantClear(&propertyValue);
}
if(S_OK == result)
{
HRESULT hResult;
LPWSTR pFileName = NULL;
hResult = spDeviceValues->GetStringValue(WPD_OBJECT_ORIGINAL_FILE_NAME, &pFileName);
}
}
}
}
return m_pFnTrueDelete(pTHIS, dwOptions, pObjectIDs, ppResults);
}