HI。请问你能帮帮我吗。如何显示标准窗口“文件属性”对话框中的文件列表,但文件有不同的位置? 例如:
d:\
d:\图片
E:\ TEXT.TXT
我找到了一个例子,它运行良好:
function SHMultiFileProperties(pDataObj: IDataObject; Flag: DWORD): HRESULT;
stdcall; external 'shell32.dll';
function GetFileListDataObject(Files: TStrings): IDataObject;
type
PArrayOfPItemIDList = ^TArrayOfPItemIDList;
TArrayOfPItemIDList = array[0..0] of PItemIDList;
var
Malloc: IMalloc;
Root: IShellFolder;
p: PArrayOfPItemIDList;
chEaten, dwAttributes: ULONG;
i, FileCount: Integer;
begin
Result := nil;
FileCount := Files.Count;
if FileCount = 0 then Exit;
OleCheck(SHGetMalloc(Malloc));
OleCheck(SHGetDesktopFolder(Root));
p := AllocMem(SizeOf(PItemIDList) * FileCount);
try
for i := 0 to FileCount - 1 do
try
if not (DirectoryExists(Files[i]) or FileExists(Files[i])) then Continue;
OleCheck(Root.ParseDisplayName(GetActiveWindow,
nil,
PWideChar(WideString(Files[i])),
chEaten,
p^[i],
dwAttributes));
except
end;
OleCheck(Root.GetUIObjectOf(GetActiveWindow,
FileCount,
p^[0],
IDataObject,
nil,
Pointer(Result)));
finally
for i := 0 to FileCount - 1 do
begin
if p^[i] <> nil then Malloc.Free(p^[i]);
end;
FreeMem(p);
end;
end;
procedure ShowFileProperties(Files: TStrings; aWnd: HWND);
type
PArrayOfPItemIDList = ^TArrayOfPItemIDList;
TArrayOfPItemIDList = array[0..0] of PItemIDList;
var
Data: IDataObject;
begin
if Files.Count = 0 then Exit;
Data := GetFileListDataObject(Files);
SHMultiFileProperties(Data, 0);
end;
但是当我传递一个驱动器号时,它会显示一个空的“文件属性”对话框:
///
SL.Add('D:\');
ShowFileProperties(SL, Handle);
我有另一个例子:
Procedure ShowFileProperties(Const filename: String);
Var
sei: TShellExecuteinfo;
Begin
FillChar(sei,sizeof(sei),0);
sei.cbSize := sizeof(sei);
sei.lpFile := Pchar(filename);
sei.lpVerb := 'Properties';
sei.fMask := SEE_MASK_INVOKEIDLIST;
ShellExecuteEx(@sei);
End;
它还会显示“文件属性”对话框,但不幸的是仅显示一个文件。如何在此示例中传递具有不同位置的多个文件???
我还找到了另一个源码,它有我需要的程序,但它们要求文件位于同一个文件夹中。这是一个链接:link text