Thread View: borland.public.cppbuilder.nativeapi
7 messages
7 total messages
Started by Asger Jørgensen
Wed, 17 Oct 2007 11:28
FindFirst vs. PIDL
Author: Asger Jørgensen
Date: Wed, 17 Oct 2007 11:28
Date: Wed, 17 Oct 2007 11:28
14 lines
1315 bytes
1315 bytes
Hi there I am trying to learn here. I have a program that search the disk for all folders and files using FindFirstFile, FindNextFile. If it is possible I would like to try and use PIDL's instead, but I have newer worked with PIDL's. If someone could give me some pointer on how to go about this, I will apriciate it very much. Thanks in advance Asger
Re: FindFirst vs. PIDL
Author: Mehmet Caner
Date: Wed, 17 Oct 2007 14:37
Date: Wed, 17 Oct 2007 14:37
1 lines
1099 bytes
1099 bytes
http://216.101.185.148/scripts/isapi.dll/article?id=02A8168A&article=1603870
Re: FindFirst vs. PIDL
Author: 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
Re: FindFirst vs. PIDL
Author: Ed Mulroy [TeamB]
Date: Wed, 17 Oct 2007 17:44
Date: Wed, 17 Oct 2007 17:44
7 lines
1149 bytes
1149 bytes
Now there is an exotic problem with a non-obvious solution. I'm keeping a copy of that one! . Ed > Remy Lebeau wrote in message > news:4716407d$1@newsgroups.borland.com...
Re: FindFirst vs. PIDL
Author: Remy Lebeau (TeamB)
Date: Wed, 17 Oct 2007 19:48
Date: Wed, 17 Oct 2007 19:48
15 lines
1524 bytes
1524 bytes
"Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote in message news:471649f1$1@newsgroups.borland.com... > Now there is an exotic problem with a non-obvious solution. > I'm keeping a copy of that one! Pretty much everything in Windows is represented by ITEMIDLIST and IShellFolder, especially virtual/special folders that don't have physical filenames/paths, but also physical filenames/path are represented as well. So it is good to know what Windows is doing internally to access those kinds of things generically. Gambit
Re: FindFirst vs. PIDL
Author: Asger Jørgensen
Date: Wed, 17 Oct 2007 23:18
Date: Wed, 17 Oct 2007 23:18
19 lines
1250 bytes
1250 bytes
Thanks Remy This looks just like, what I need. One little error though. This line: if( SUCCEEDED(SubFolder->GetAttributesOf(1, &pidlItem, &ulAttr)) ) Should be: if( SUCCEEDED(SubFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidlItem, &ulAttr)) ) But of cource You know that..;-) Thanks again Kind regards Asger
Re: FindFirst vs. PIDL
Author: Asger Jørgensen
Date: Wed, 17 Oct 2007 23:19
Date: Wed, 17 Oct 2007 23:19
7 lines
1017 bytes
1017 bytes
Thanks for the link Mehmet Combined with what Remy provided I think I got it now. Kind regards Asger
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads