Article View: borland.public.cppbuilder.nativeapi
Article #1108Re: SHGetDataFromIDList fails on temporary internet files
From: Asger Jørgensen
Date: Tue, 23 Oct 2007 11:09
Date: Tue, 23 Oct 2007 11:09
162 lines
5957 bytes
5957 bytes
Hi Remy
In article <471d25c3$1@newsgroups.borland.com>
no.spam@no.spam.com
Remy Lebeau (TeamB) says:
>
> "Asger Jørgensen" <junk@Asger-P.dk> wrote in message
> news:MPG.21872af521ad1e3a989874@newsgroups.borland.com...
>
> That is not what I was referring to. You have not shown any code that is
> operating on the individual files. Only the code that is looping through
> the folders.
And that is the only thing I do I gather the foldernames,
filenames and the size of the files.
Then I store all the information in a nested std::list's
> So you have not shown how you are gathering error information
> or how you are outputting it.
Just by looking at the return value of SHGetDataFromIDList
for outputting I just use fprintf to a file opened with fopen
in text apend mode.
> But in any case, I just ran the code I gave you earlier and I have no
> problem using SHGetDataFromIDList() to retreive the sizes of the files in
> the "Temporary Internet Files" folder on my machine. It does not fail on me
> like it does on you.
On my win2k it doesn't fail either, so maybe it has
something to do with my XP pro ver. 2002 SP2 or just my PC
> So I have to think that you are still using it wrong
> somehow. Can you please show a complete compilable example of what you are
> trying to do?
I don't think I do much more the what You showed but below is
my code.
Thanks for Your help
Kind regards
Asger
void __fastcall TDriveBut::StartPidlSearch(WideString Path,
TTreeNodes *TreeNodes,
TTreeNode *AboveNode)
{
IShellFolder *Desktop = NULL;
if( SUCCEEDED(SHGetDesktopFolder(&Desktop)) )
{
ULONG eaten = 0;
LPITEMIDLIST pidlFolder = NULL;
if( SUCCEEDED(Desktop->ParseDisplayName(NULL, NULL,
Path, &eaten, &pidlFolder, NULL)) )
{
FRootFolder->GoFindAllPidls(Desktop, pidlFolder,
TreeNodes, AboveNode);
CoTaskMemFree(pidlFolder);
}
Desktop->Release();
}
}
//---------------------------------------------------------
void __fastcall TFolder::GoFindAllPidls(IShellFolder
*ParentFolder,
LPITEMIDLIST pidlSubFolder, TTreeNodes *TreeNodes,
TTreeNode *AboveNode)
{
Application->ProcessMessages(); //updating some labels
elsewhere
FNode = AboveNode;
FNode->Data = this;
bool UseFindFirstFile = false;
if(Stop)return;
IShellFolder *SubFolder = NULL;
if( FAILED(ParentFolder->BindToObject(pidlSubFolder, NULL,
IID_IShellFolder, (LPVOID*)&SubFolder)) )
return;
//
IEnumIDList *Enum = NULL;
DWORD dwFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS |
SHCONTF_INCLUDEHIDDEN;
if( FAILED(SubFolder->EnumObjects(NULL, dwFlags, &Enum)) )
{
SubFolder->Release();
return;
}
LPITEMIDLIST pidlItem;
while( Enum->Next(1, &pidlItem, NULL) == S_OK )
{
WIN32_FIND_DATA Wfd = {0};
if( FAILED(SHGetDataFromIDList(SubFolder, pidlItem,
SHGDFIL_FINDDATA, &Wfd, sizeof(Wfd) ) ) )
{
UseFindFirstFile = true;
CoTaskMemFree(pidlItem);
break; // Jump out of the Enumaration and use
GoFindAllFolderAndFiles
}
char* FileName = Wfd.cFileName;
if(Wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
{
ULONG ulAttr = SFGAO_LINK; //checking for shortcuts
to folders
if( FAILED(SubFolder->GetAttributesOf(1,
(LPCITEMIDLIST*)&pidlItem, &ulAttr)) )
{
CoTaskMemFree(pidlItem);
continue;
}
//::: Removed Adding to my own List
TTreeNode *NewNode;
NewNode = TreeNodes->AddChild(FNode, FileName);
NewNode->ImageIndex = IconIds->Folder;
NewNode->SelectedIndex = IconIds->OpenFolder;
if(!FOwner)TreeNodes->Item[0]->Expanded = true;
//if shortcuts to folders dont go deeper
if(ulAttr&SFGAO_LINK);
else
NewFolder->GoFindAllPidls(SubFolder, pidlItem,
TreeNodes, NewNode);
}else{
// removed adding to my own filelist
}
CoTaskMemFree(pidlItem);
}
Enum->Release();
SubFolder->Release();
if(UseFindFirstFile)
{ // if it fails use the old style FindFirstFile
ClearLists();
GetFFullPath();
GoFindAllFoldersAndFiles(FFullPath, TreeNodes,
AboveNode);
}else
std::sort(Files.begin(), Files.end(), CmpSortFiles());
}
//----------------------------------------------------------
Technical Details
Message-ID:
<MPG.2187f4c124611265989877@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<MPG.218245b2537e015098985c@newsgroups.borland.com> <471833b6$1@newsgroups.borland.com> <MPG.21826e95e6e7cbbe98985e@newsgroups.borland.com> <4718e0b4@newsgroups.borland.com> <MPG.2183458093d06de2989860@newsgroups.borland.com> <471ccfd6@newsgroups.borland.com> <MPG.21872af521ad1e3a989874@newsgroups.borland.com> <471d25c3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9b1c408e0dae3bef X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,UTF8 From: Asger Jørgensen <junk@Asger-P.dk> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: SHGetDataFromIDList fails on temporary internet files Date: Tue, 23 Oct 2007 13:09:08 +0200 Message-ID: <MPG.2187f4c124611265989877@newsgroups.borland.com> References: <MPG.218245b2537e015098985c@newsgroups.borland.com> <471833b6$1@newsgroups.borland.com> <MPG.21826e95e6e7cbbe98985e@newsgroups.borland.com> <4718e0b4@newsgroups.borland.com> <MPG.2183458093d06de2989860@newsgroups.borland.com> <471ccfd6@newsgroups.borland.com> <MPG.21872af521ad1e3a989874@newsgroups.borland.com> <471d25c3$1@newsgroups.borland.com> Organization: Asger-P MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable User-Agent: MicroPlanet-Gravity/2.70.2067 NNTP-Posting-Host: 83.73.201.25 X-Trace: newsgroups.borland.com 1193137735 83.73.201.25 (23 Oct 2007 04:08:55 -0700) Lines: 162 Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail