Click here to Skip to main content
16,013,465 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Device driver ? Pin
5-Jun-02 23:12
suss5-Jun-02 23:12 
GeneralMSDN Integration with Visual C++.NET Pin
Orbital^3-Jun-02 0:45
Orbital^3-Jun-02 0:45 
GeneralRe: MSDN Integration with Visual C++.NET Pin
Nish Nishant3-Jun-02 0:58
sitebuilderNish Nishant3-Jun-02 0:58 
GeneralRe: MSDN Integration with Visual C++.NET Pin
Orbital^3-Jun-02 1:08
Orbital^3-Jun-02 1:08 
GeneralRe: MSDN Integration with Visual C++.NET Pin
Anders Molin3-Jun-02 2:35
professionalAnders Molin3-Jun-02 2:35 
GeneralRe: MSDN Integration with Visual C++.NET Pin
Orbital^3-Jun-02 3:03
Orbital^3-Jun-02 3:03 
GeneralRe: MSDN Integration with Visual C++.NET Pin
Anders Molin3-Jun-02 7:13
professionalAnders Molin3-Jun-02 7:13 
GeneralEnumObjects doesen't work when using recursive function. Pin
redeemer3-Jun-02 0:28
redeemer3-Jun-02 0:28 
I have made this function that takes a pointer to a ITEMIDLIST as a parameter that points to a folder and then loops through the items in the folder. If it is a file it adds it to the listview control, and if it is a folder it calls itself. But when it encounters a folder and calls itself the first time, the EnumObjects function fails. The ITEMIDLIST i pass in the function is the return value of the SHBrowseForFolder function. Anyone know what's wrong? Here's the code:
void AddFilesFromFolder(ITEMIDLIST *pIdl)
{
	if (pIdl)
	{
		IShellFolder *pBrowse = NULL;
		LPENUMIDLIST pFolder = NULL;
		LPMALLOC pMalloc = NULL;
		ITEMIDLIST *pNewId = NULL;
		STRRET strDispName;
		LVITEM lvItem;
		RECT rMain;
		RECT rAdd;
		char szCurrentFile[MAX_PATH+1+5];
		char szFolderPath[MAX_PATH+1];
		DWORD pActual = 0;
		DWORD dwAttrib;
		IShellFolder *CurrentFolder;
		HRESULT err;

		err = SHGetDesktopFolder (&CurrentFolder);

		if (err == NOERROR)
		{
			SHGetMalloc(&pMalloc);
			CurrentFolder->BindToObject(pIdl, NULL, IID_IShellFolder, (LPVOID*)&pBrowse);
			pBrowse->GetDisplayNameOf(pIdl, SHGDN_INFOLDER, &strDispName);
			err = pBrowse->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pFolder);
			if (err == NOERROR)
			{
				SHGetPathFromIDList(pIdl, szFolderPath);
				/*hDialog = CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_ADDFILES), ghWnd, DialogAddProc);
				GetWindowRect(ghWnd, &rMain);
				GetWindowRect(hDialog, &rAdd);
				MoveWindow(hDialog, (((rMain.right-rMain.left)/2)-((rAdd.right-rAdd.left)/2) + rMain.left), (((rMain.bottom-rMain.top)/2)-((rAdd.bottom-rAdd.top)/2) + rMain.top), rAdd.right-rAdd.left, rAdd.bottom-rAdd.top, FALSE); //Center dialog relative to main window
				ShowWindow (hDialog, SW_SHOW);
				UpdateWindow (hDialog);
				SetDlgItemText(hDialog, IDC_STATUS, "Adding:");*/

				lvItem.mask = LVIF_IMAGE | LVIF_TEXT;

				while (pFolder->Next(1, &pNewId, &pActual) != S_FALSE)
				{
					dwAttrib = SFGAO_FOLDER;
					pBrowse->GetAttributesOf(1, (LPCITEMIDLIST*)&pNewId, &dwAttrib);
						
					if (!(dwAttrib & SFGAO_FOLDER))
					{
						pBrowse->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strDispName);
						PathCombine(gszPath, szFolderPath, strDispName.cStr);
							
						/*sprintf(szCurrentFile, "\"%s\"...", gszPath); //"<path>"...
						SetDlgItemText(hDialog, IDC_CURRENTFILE, szCurrentFile);*/

						GetID3();
						FillInfo();
						ListAddItem();
					}

					if (dwAttrib & SFGAO_FOLDER)
					{
						pBrowse->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strDispName);
						AddFilesFromFolder(pNewId);
					}
				}

				pMalloc->Free(pNewId);
				pMalloc->Release();
				//EndDialog(hDialog, true);
				gbFileOpen = true;
				pFolder->Release();
			}

			CurrentFolder->Release();
		}
	}
}


Thankyou all!
GeneralRe: EnumObjects doesen't work when using recursive function. Pin
_Magnus_3-Jun-02 1:04
_Magnus_3-Jun-02 1:04 
GeneralRe: EnumObjects doesen't work when using recursive function. Pin
redeemer3-Jun-02 2:12
redeemer3-Jun-02 2:12 
GeneralRe: EnumObjects doesen't work when using recursive function. Pin
_Magnus_3-Jun-02 3:53
_Magnus_3-Jun-02 3:53 
GeneralAcrobat 5.0 and PDFWriter Pin
3-Jun-02 0:25
suss3-Jun-02 0:25 
GeneralRe: Acrobat 5.0 and PDFWriter Pin
John M. Drescher3-Jun-02 17:34
John M. Drescher3-Jun-02 17:34 
GeneralPGP riddle solved Pin
Nish Nishant2-Jun-02 23:58
sitebuilderNish Nishant2-Jun-02 23:58 
Questionhow to write a small debugger? Pin
hwnd2-Jun-02 22:19
hwnd2-Jun-02 22:19 
AnswerRe: how to write a small debugger? Pin
2-Jun-02 22:30
suss2-Jun-02 22:30 
GeneralVC7 & CString : LNK2005 error Pin
2-Jun-02 22:26
suss2-Jun-02 22:26 
GeneralRe: VC7 & CString : LNK2005 error Pin
3-Jun-02 21:31
suss3-Jun-02 21:31 
GeneralRe: VC7 & CString : LNK2005 error Pin
Mike Nordell3-Jun-02 22:57
Mike Nordell3-Jun-02 22:57 
GeneralRe: VC7 & CString : LNK2005 error Pin
3-Jun-02 23:14
suss3-Jun-02 23:14 
GeneralRe: VC7 & CString : LNK2005 error Pin
Mike Nordell5-Jun-02 1:26
Mike Nordell5-Jun-02 1:26 
GeneralRe: VC7 & CString : LNK2005 error Pin
6-Jun-02 23:03
suss6-Jun-02 23:03 
GeneralRe: VC7 & CString : LNK2005 error Pin
18-Jun-02 6:14
suss18-Jun-02 6:14 
GeneralDeskband Pin
2-Jun-02 22:10
suss2-Jun-02 22:10 
GeneralRe: Deskband Pin
Demián Gutierrez6-May-05 9:30
Demián Gutierrez6-May-05 9:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.