开发者

How to show Properties Dialog for multiple Files with different locations

开发者 https://www.devze.com 2023-01-27 09:12 出处:网络
HI. Could you help me please. How to show standard windows \"File Properties\" dialog for a list of files, but the files have different location?

HI. Could you help me please. How to show standard windows "File Properties" dialog for a list of files, but the files have different location? For ex:

D:\

D:开发者_运维问答\Pictures

E:\Text.txt

I've found an example and it works fine:

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;

But when I pass a Drive letter, it shows an empty "File Properties" dialog:

///
SL.Add('D:\');
ShowFileProperties(SL, Handle);

I have another example:

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;

It also shows "File Properties" Dialog , but unfortunately for one file only. How to pass multiple files with different locations in this example???

I also found another source which has the procedures I need but they require files to be located in the same folder. Here is a link: link text


I would take a look at the code example found here. I think you should be able to use that idea to pass in multiple file paths.

0

精彩评论

暂无评论...
验证码 换一张
取 消