I like to use the windows properties dialog to display the properties of
mutiple files and folders. The filenames of the files/folders are in a
TStringList. I like to use the code as shown below but my problem is how to
convert the TStringlist to a PItemIdList. I did a Google search but most of
the answers are based on displaying the properties of single files or
folders.
Thanks very much for your time.
function DisplayPropDialog(const Handle: HWND; const Item: PItemIdList):
Boolean;
var
Info: TShellExecuteInfo;
begin
FillChar(Info, SizeOf(Info), #0);
with Info do
begin
cbSize := SizeOf(Info);
nShow := SW_SHOW;
lpIDList := Item;
fMask := SEE_MASK_INVOKEIDLIST or SEE_MASK_IDLIST;
Wnd := Handle;
lpVerb := PChar('properties');
end;
Result := ShellExecuteEx(@Info);
end;
Jack
As far as I know, it is not possible to identify more than one object
with an item identifier list.
You could try to specify all file names (separated by spaces) in lpFile.
HTH
Clemens
I suspect you misunderstand what a PItemIdList is. It does not correlate
with a
list of files. The PItemIdList is a 'list' of 'id's which together
constitute a pointer
or path to a *single* specific file, folder or virtual object.
Here's a function to get a pItemIdList (often referred to as a pidl) for a
specific
file or folder:
var
// ShellMalloc can be assigned in the initialization section as it
// is needed to release 'pidls' which are assigned using
// the shell's memory allocator...
ShellMalloc: IMalloc;
//nb: it is the task of the *calling* routine to free the returned pidl
//when it's no longer required [ eg using ShellMalloc.Free() ]...
function GetPidlFromPath(path: string): pItemIdList;
var
dummy,dummy2: DWORD;
widePath: WideString;
DesktopShellFolder: IShellFolder;
begin
widePath := path;
if FAILED(SHGetDesktopFolder(DesktopShellFolder)) or
FAILED(DesktopShellFolder.ParseDisplayName(0,
nil,PWideChar(widePath),dummy,result,dummy2)) then result := nil;
end;
initialization
SHGetMalloc(ShellMalloc);
There is an alternative that can display the properties dialog for a
number of shell objects.
1. Get the IShellFolder interface of the desktop folder
(ShGetDesktopFolder).
2. Use its ParseDisplayName to get an absolute PIDL for every file and
put the PIDLs in an array of PItemIDList.
3. Use its GetUIObjectOf to get an IContextMenu for all the items. Set
cidl to the number of files and aPidl to the address of the 1st
element of the array of PIDLs.
4. Use IContextMenu.InvokeCommand to invoke the 'properties' verb for
all the files.
Hope this helps. Don't forget to free the PIDLs when you're done.