Delphi 如何显示具有不同位置的多个文件的属性对话框
嗨。你能帮帮我吗。如何显示文件列表的标准windows“文件属性”对话框,但文件的位置不同? 例如: D:\Delphi 如何显示具有不同位置的多个文件的属性对话框,delphi,file,properties,copy,cut,Delphi,File,Properties,Copy,Cut,嗨。你能帮帮我吗。如何显示文件列表的标准windows“文件属性”对话框,但文件的位置不同? 例如: D:\ D:\Pictures E:\Text.txt 我找到了一个例子,效果很好: function SHMultiFileProperties(pDataObj: IDataObject; Flag: DWORD): HRESULT; stdcall; external 'shell32.dll'; function GetFileListDataObject(Files:
D:\Pictures
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;
我还有一个例子:
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;
它还显示“文件属性”对话框,但不幸的是,只有一个文件。在本例中,如何传递具有不同位置的多个文件
我还找到了另一个源,其中包含我需要的过程,但它们要求文件位于同一文件夹中。这里有一个链接:我想看看找到的代码示例。我认为您应该能够使用这种想法来传递多个文件路径。我将查看找到的代码示例。我认为你应该能够使用这个想法来传递多个文件路径。问问自己,如果你要吃掉它引发的异常,为什么要费心调用
ocheck
?如果你要吃掉它引发的异常,为什么要费心调用ocheck
?
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;