Click here to Skip to main content
15,925,723 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Mutex problem Pin
Mike Nordell6-Jun-02 9:57
Mike Nordell6-Jun-02 9:57 
GeneralRe: Mutex problem Pin
John M. Drescher6-Jun-02 10:06
John M. Drescher6-Jun-02 10:06 
GeneralRe: Mutex problem Pin
John M. Drescher6-Jun-02 10:11
John M. Drescher6-Jun-02 10:11 
Generalstring to wstring conversion Pin
5-Jun-02 7:41
suss5-Jun-02 7:41 
GeneralRe: string to wstring conversion Pin
Mike Nordell5-Jun-02 7:57
Mike Nordell5-Jun-02 7:57 
GeneralVC++ XML integration Pin
5-Jun-02 7:31
suss5-Jun-02 7:31 
GeneralRe: VC++ XML integration Pin
Nemanja Trifunovic5-Jun-02 7:48
Nemanja Trifunovic5-Jun-02 7:48 
GeneralError when using EnumObjects function. Pin
redeemer5-Jun-02 7:16
redeemer5-Jun-02 7:16 
I have a function which takes the IShellFolder object for a folder as a parameter, and loops through all the items in the folder. If it is a file, it adds it to a ListView control, and if it is a folder it calls itself. But the first time the function encounters a folder and calls itself, the pIShell->EnumObjects returns the error code -2147023673 which, according to the Error Lookup, is "The operation was canceled by the user.".

Can anyone figure out what's wrong? Here's the code:

void AddFilesFromFolder(IShellFolder *pIShell)
{
	if (pIShell)
	{
		IShellFolder *pBrowse = NULL;
		LPENUMIDLIST pFolder = NULL;
		LPMALLOC pMalloc = NULL;
		ITEMIDLIST *pNewId = NULL;
		STRRET strDispName;
		LVITEM lvItem;
		DWORD pActual = 0;
		DWORD dwAttrib;
		IShellFolder *CurrentFolder;
		HRESULT err;

		err = SHGetDesktopFolder (&CurrentFolder);

		if (err == NOERROR)
		{
			SHGetMalloc(&pMalloc);
			err = pIShell->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pFolder);
			if (err == NOERROR)
			{

				lvItem.mask = LVIF_IMAGE | LVIF_TEXT;

				while (pFolder->Next(1, &pNewId, &pActual) != S_FALSE)
				{
					dwAttrib = SFGAO_FOLDER;
					pIShell->GetAttributesOf(1, (LPCITEMIDLIST*)&pNewId, &dwAttrib);
						
					if (!(dwAttrib & SFGAO_FOLDER))
					{
						pIShell->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strDispName);

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

					if (dwAttrib & SFGAO_FOLDER)
					{
						CurrentFolder->BindToObject(pNewId, NULL, IID_IShellFolder, (LPVOID*)&pBrowse);
						Add2(pBrowse);
					}
				}

				pMalloc->Free(pNewId);
				pMalloc->Release();
				gbFileOpen = true;
				pFolder->Release();
			}

			CurrentFolder->Release();
		}
	}
}


Thankyou.

-Rune Svendsen
GeneralRe: Error when using EnumObjects function. Pin
Cathy6-Jun-02 9:43
Cathy6-Jun-02 9:43 
GeneralMSChart labels Pin
5-Jun-02 5:50
suss5-Jun-02 5:50 
GeneralRe: MSChart labels Pin
Richard Ellis5-Jun-02 20:36
Richard Ellis5-Jun-02 20:36 
GeneralRe: MSChart labels Pin
Ruca20-Aug-02 1:08
Ruca20-Aug-02 1:08 
GeneralRe: MSChart labels Pin
Ruca20-Aug-02 5:28
Ruca20-Aug-02 5:28 
GeneralRe: MSChart labels Pin
Ruca20-Aug-02 6:43
Ruca20-Aug-02 6:43 
GeneralRe: MSChart labels Pin
Richard Ellis20-Aug-02 13:20
Richard Ellis20-Aug-02 13:20 
QuestionIs there an ActiveX Control like Favorites? Pin
Dov Sherman5-Jun-02 5:01
Dov Sherman5-Jun-02 5:01 
AnswerRe: Is there an ActiveX Control like Favorites? Pin
Tomasz Sowinski5-Jun-02 5:08
Tomasz Sowinski5-Jun-02 5:08 
GeneralRe: Is there an ActiveX Control like Favorites? Pin
Dov Sherman5-Jun-02 5:51
Dov Sherman5-Jun-02 5:51 
GeneralRe: Is there an ActiveX Control like Favorites? Pin
Tomasz Sowinski5-Jun-02 5:53
Tomasz Sowinski5-Jun-02 5:53 
GeneralRe: Is there an ActiveX Control like Favorites? Pin
Dov Sherman5-Jun-02 6:52
Dov Sherman5-Jun-02 6:52 
GeneralHelp!! Pin
chaolong5-Jun-02 4:37
chaolong5-Jun-02 4:37 
GeneralRe: Help!! Pin
Michael P Butler5-Jun-02 5:00
Michael P Butler5-Jun-02 5:00 
GeneralRe: Help!! Pin
chaolong5-Jun-02 4:59
chaolong5-Jun-02 4:59 
GeneralRe: Help!! Pin
Rage5-Jun-02 5:23
professionalRage5-Jun-02 5:23 
GeneralProblem with Creation Pin
Big B5-Jun-02 4:19
Big B5-Jun-02 4:19 

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.