Hi All,
I am writing application, which gets list of image files under a particular
directory/Camera namespace NSE and displays image thumbnails. Recently I
added code to refresh my Tree control view, when devices are dynamically
added/removed. I implemented this code by listening for WM_DEVICECHANGE
notification.
Here are the steps
- Camera is connected to Computer
- First time App runs, I could display images from Camera namespace device.
- I remove the camera by removing USB connection.
- Treeview updates and doesn't display NSE.
- I insert the Camera back . Tree view displays NSE.
- I click NSE. I try to get list of files. Here it FAILS. I tried updating
Shell Cache on MyComputer/Desktop Nodes.
- I could get properties AND attributes of NSE device.
The call "spEnumIDList->Next(1, &lpRelPIDL, &ulPIDLsFetched ))" returns
FALSE.
Any ideas why. TIA.
Here is code snippet to get list of files.
CComPtr<IEnumIDList> spEnumIDList;
CComPtr<IShellFolder> spShellDesktop;
CComPtr<IShellFolder> spShellFolder;
LPITEMIDLIST lpRelPIDL = NULL;
ULONG ulPIDLsFetched =0;
HRESULT hr;
CString temp;
hr = ::SHGetMalloc(&spMalloc);
if (FAILED(hr))
return FALSE;
hr = ::SHGetDesktopFolder(&spShellDesktop);
if (FAILED(hr))
{
return FALSE;
}
// Now, get the IShellFolder interface for this
folder/object/virtual-folder
hr = spShellDesktop->BindToObject(m_lpParentFolderPIDL, 0,
IID_IShellFolder, (void**)&spShellFolder);
if (FAILED(hr))
{
return FALSE;
}
// Enumerate the objects underneath it.
hr = spShellFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS, &spEnumIDList);
if (FAILED(hr))
{
return FALSE;
}
// SECOND Time , spEnumIDList returns FALSE.
while(S_OK == spEnumIDList->Next(1, &lpRelPIDL, &ulPIDLsFetched ))
{
// Get PIDLS, Open file , Read it.
ThanksQuote:}
Venki