Delphi SHMultiFileProperties查看多个文件属性
2013-05-23 13:23
363 查看
library Properties; { Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. } uses Windows, Dialogs, SysUtils, Classes, ActiveX, ShlObj, ComObj; {$R *.res} 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; function SplitString(const source, ch: string): TStringList; var temp, t2: string; i: integer; begin result := TStringList.Create; temp := source; i := pos(ch, source); while i <> 0 do begin t2 := copy(temp, 0, i - 1); if (t2 <> '') then result.Add(t2); delete(temp, 1, i - 1 + Length(ch)); i := pos(ch, temp); end; result.Add(temp); end; procedure ShowProperties(AFiles: PChar); stdcall; var oList:TStrings; begin oList:= SplitString(AFiles, ';'); ShowFileProperties(oList, 0); end; exports ShowProperties name 'ShowProperties'; begin end.
相关文章推荐
- Delphi SHMultiFileProperties查看多个文件属性
- C# SHMultiFileProperties查看多个文件属性
- C# SHMultiFileProperties查看多个文件属性
- 调用windows api SHMultiFileProperties 显示多文件的汇总属性
- linux 下查看文件属性的命令
- 使用枚举单例实现Xml、properties属性配置文件的操作
- java 读取 properties 属性文件
- stat 查看文件状态等属性
- 通过ls查看文件属性
- java读写Properties属性文件公用方法
- Linux文件的隐藏属性 / 设定指令 chattr / 查看指令 lsattr(鸟哥的Linux私房菜基础学习篇第三版-第七章)
- Linux磁盘和文件系统管理(4)_文件系统属性查看 修改
- 使用JAVA读写Properties属性文件
- 使用JAVA读写Properties属性文件
- 解决修改properties 属性文件存在缓存问题,附带操作properties文件工具类
- 得到src目录下的properties文件属性
- Eclipse查看.properties文件中文乱码
- 制作FAT12软盘以查看软盘的根目录条目+文件属性+文件内容
- spring 通过@Value 获取properties文件中设置了属性 ,与@Value # 和$的区别
- hibernate.properties文件配置属性归纳