Article View: borland.public.cppbuilder.nativeapi
Article #1150Re: FindFirst vs. PIDL
From: Remy Lebeau (TeamB)
Date: Wed, 17 Oct 2007 17:03
Date: Wed, 17 Oct 2007 17:03
74 lines
3720 bytes
3720 bytes
"Asger J๏ฟฝrgensen" <junk@Asger-P.dk> wrote in message
news:MPG.218010608a8f1194989854@newsgroups.borland.com...
> If it is possible I would like to try and use PIDL's
> instead
You will have to use the IShellFolder interface for that. Use
SHGetDesktopFolder() to get the IShellFolder for the top-level Desktop
namespace, then use its ParseDisplayName() and BindToObject() methods to get
the IShellFolder for the specific folder that you want to begin searching
from, then use that IShellFolder's EnumObjects() method to enumerate its
subfolders and files. For each subfolder, call the parent IShellFolder's
BindToObject() to get the IShellFolder for the subfolder, then call its
EnumObjects() method, repeating recursively as needed. For example:
void SearchFolder(IShellFolder *ParentFolder, LPITEMIDLIST
pidlSubFolder)
{
IShellFolder *SubFolder = NULL;
if( SUCCEEDED(ParentFolder->BindToObject(pidlSubFolder, NULL,
IID_IShellFolder, (LPVOID*)&SubFolder)) )
{
IEnumIDList *Enum = NULL;
if( SUCCEEDED(SubFolder->EnumObjects(NULL, SHCONTF_FOLDERS |
SHCONTF_NONFOLDERS, &Enum)) )
{
LPITEMIDLIST pidlItem;
while( Enum->Next(1, &pidlItem, NULL) == S_OK )
{
// compare pidlItem to your search criteria as
needed,
// such as by calling
SubFolder->GetDisplayNameOf(pidlItem, ...)
// and other IShellFolder methods to get information
// about the current item...
ULONG ulAttr = 0;
if( SUCCEEDED(SubFolder->GetAttributesOf(1,
&pidlItem, &ulAttr)) )
{
if( ulAttr & SFGAO_FOLDER )
SearchFolder(SubFolder, pidlItem);
}
CoTaskMemFree(pidlItem);
}
Enum->Release();
}
SubFolder->Release();
}
}
{
IShellFolder *Desktop = NULL;
if( SUCCEEDED(SHGetDesktopFolder(&Desktop)) )
{
ULONG eaten = 0;
LPITEMIDLIST pidlFolder = NULL;
if( SUCCEEDED(Desktop->ParseDisplayName(NULL, NULL,
WideString("The starting path here"), &eaten, &pidlFolder, NULL)) )
{
SearchFolder(Desktop, pidlFolder);
CoTaskMemFree(pidlFolder);
}
Desktop->Release();
}
}
Gambit
Technical Details
Message-ID:
<4716407d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<MPG.218010608a8f1194989854@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e6fda3151eebe703 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <MPG.218010608a8f1194989854@newsgroups.borland.com> Subject: Re: FindFirst vs. PIDL Date: Wed, 17 Oct 2007 10:03:15 -0700 Lines: 76 Organization: Lebeau Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 207.178.157.90 Message-ID: <4716407d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1192640637 207.178.157.90 (17 Oct 2007 10:03:57 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail