was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1548)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (127)
Strings (83)
System (268)
VCL (243)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

32 Visitors Online


 
...den Eigenschaften Dialog mehrerer Dateien anzeigen lassen?
Autor: Kingron
Homepage: http://kingron.delphibbs.com
[ Tip ausdrucken ]  

Tip Bewertung (11):  
     


{ Copyright Kingron 2005 }
{ For Windows 2000 or Higher, Shell32.dll version 5.0 or later }

uses ActiveX, ShlObj, ComObj;

function SHMultiFileProperties(pDataObj: IDataObject; Flag: DWORD): HRESULT;
  stdcallexternal '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;


// Example:
// Beispiel:

procedure TForm1.Button1Click(Sender: TObject);
begin
  if 
OpenDialog1.Execute then
    
Memo1.Lines.AddStrings(OpenDialog1.Files);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  
ShowFileProperties(Memo1.Lines, 0);
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners