Windows Portable device event monitoring using MFC C++
Aparna S A
6
Reputation points
I need to develop an application to monitor events on Portable devices using C++ MFC. I'm using WPD API for the same. But encountering a few issues. I am not getting the Filename in case of the delete operation. and also not able to register for more than one Portable device.
HRESULT hr = S_OK;
PWSTR eventCookie = nullptr;
ComPtr<IPortableDevice> device;
device = nullptr;
hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
DWORD pnpDeviceIDCount = EnumerateAllDevices();
for(int i=0;i<pnpDeviceIDCount;i++)
{
ChooseDevice(&device,i);
if (device == nullptr)
{
continue ;
}
RegisterForEventNotifications(device.Get(), &eventCookie);
}
CoUninitialize();