searchcode logo

delcos /components/jcl/examples/windows/filesummary/FileSummaryDemoMain.pas

git clone git://github.com/padcom/delcos.git

Code Metrics - Raw File
  1. unit FileSummaryDemoMain;
  2.  
  3. {$I jcl.inc}
  4. {$I windowsonly.inc}
  5.  
  6. interface
  7.  
  8. uses
  9. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  10. Dialogs, StdCtrls, FileCtrl, ActiveX, JclNTFS;
  11.  
  12. type
  13. TFormMain = class(TForm)
  14. DriveComboBox1: TDriveComboBox;
  15. Memo1: TMemo;
  16. FileListBox1: TFileListBox;
  17. DirectoryListBox1: TDirectoryListBox;
  18. procedure FileListBox1Change(Sender: TObject);
  19. private
  20. FFileSummary: TJclFileSummary;
  21. procedure UpdateFileSummary(const FileName: string);
  22. public
  23. end;
  24.  
  25. var
  26. FormMain: TFormMain;
  27.  
  28. implementation
  29.  
  30. {$R *.dfm}
  31.  
  32. uses
  33. JclSysUtils;
  34.  
  35. procedure TFormMain.FileListBox1Change(Sender: TObject);
  36. begin
  37. if FileListBox1.FileName <> '' then
  38. UpdateFileSummary(FileListBox1.FileName);
  39. end;
  40.  
  41. procedure TFormMain.UpdateFileSummary(const FileName: string);
  42. function FileTimeToString(const FileTime: TFileTime): string;
  43. var
  44. ASystemTime: TSystemTime;
  45. begin
  46. if FileTimeToSystemTime(FileTime, ASystemTime) then
  47. Result := Format('%d/%d/%d %d:%d:%d', [ASystemTime.wYear, ASystemTime.wMonth, ASystemTime.wDay,
  48. ASystemTime.wHour, ASystemTime.wMinute, ASystemTime.wSecond])
  49. else
  50. Result := '';
  51. end;
  52. var
  53. AFilePropertySet: TJclFilePropertySet;
  54. AFileSummaryInformation: TJclFileSummaryInformation;
  55. ADocumentSummaryInformation: TJclDocSummaryInformation;
  56. AMediaFileSummaryInformation: TJclMediaFileSummaryInformation;
  57. AMSISummaryInformation: TJclMSISummaryInformation;
  58. AVideoSummaryInformation: TJclVideoSummaryInformation;
  59. AAudioSummaryInformation: TJclAudioSummaryInformation;
  60. begin
  61. Memo1.Lines.Clear;
  62. FFileSummary := TJclFileSummary.Create(FileName, fsaRead, fssDenyAll);
  63. try
  64. FFileSummary.GetPropertySet(TJclFileSummaryInformation, AFileSummaryInformation);
  65. if Assigned(AFileSummaryInformation) then
  66. try
  67. Memo1.Lines.Add('File summary');
  68.  
  69. Memo1.Lines.Add(string(' Title ' + AFileSummaryInformation.Title));
  70. Memo1.Lines.Add(string(' Subject ' + AFileSummaryInformation.Subject));
  71. Memo1.Lines.Add(string(' Author ' + AFileSummaryInformation.Author));
  72. Memo1.Lines.Add(string(' Keywords ' + AFileSummaryInformation.KeyWords));
  73. Memo1.Lines.Add(string(' Comments ' + AFileSummaryInformation.Comments));
  74. Memo1.Lines.Add(string(' Template ' + AFileSummaryInformation.Template));
  75. Memo1.Lines.Add(string(' Last author ' + AFileSummaryInformation.LastAuthor));
  76. Memo1.Lines.Add(string(' Revision numer ' + AFileSummaryInformation.RevNumber));
  77. Memo1.Lines.Add(string(' Edit time ' + FileTimeToString(AFileSummaryInformation.EditTime)));
  78. Memo1.Lines.Add(string(' Last printed time ' + FileTimeToString(AFileSummaryInformation.LastPrintedTime)));
  79. Memo1.Lines.Add(string(' Creation time ' + FileTimeToString(AFileSummaryInformation.CreationTime)));
  80. Memo1.Lines.Add(string(' Last save time ' + FileTimeToString(AFileSummaryInformation.LastSaveTime)));
  81. Memo1.Lines.Add(' Page count ' + IntToStr(AFileSummaryInformation.PageCount));
  82. Memo1.Lines.Add(' Word count ' + IntToStr(AFileSummaryInformation.WordCount));
  83. Memo1.Lines.Add(' Char count ' + IntToStr(AFileSummaryInformation.CharCount));
  84. //AFileSummaryInformation.Thumnail
  85. Memo1.Lines.Add(string(' App name ' + AFileSummaryInformation.AppName));
  86. Memo1.Lines.Add(' Security ' + IntToStr(AFileSummaryInformation.Security));
  87. finally
  88. AFileSummaryInformation.Free;
  89. end;
  90.  
  91. FFileSummary.GetPropertySet(TJclDocSummaryInformation, ADocumentSummaryInformation);
  92. if Assigned(ADocumentSummaryInformation) then
  93. try
  94. Memo1.Lines.Add('Document summary');
  95. Memo1.Lines.Add(string(' Category ' + ADocumentSummaryInformation.Category));
  96. Memo1.Lines.Add(string(' Pres format ' + ADocumentSummaryInformation.PresFormat));
  97. Memo1.Lines.Add(' Byte count ' + IntToStr(ADocumentSummaryInformation.ByteCount));
  98. Memo1.Lines.Add(' Line count ' + IntToStr(ADocumentSummaryInformation.LineCount));
  99. Memo1.Lines.Add(' Par count ' + IntToStr(ADocumentSummaryInformation.ParCount));
  100. Memo1.Lines.Add(' Slide count ' + IntToStr(ADocumentSummaryInformation.SlideCount));
  101. Memo1.Lines.Add(' Note count ' + IntToStr(ADocumentSummaryInformation.NoteCount));
  102. Memo1.Lines.Add(' Hidden count ' + IntToStr(ADocumentSummaryInformation.HiddenCount));
  103. Memo1.Lines.Add(' MM Clip count ' + IntToStr(ADocumentSummaryInformation.MMClipCount));
  104. Memo1.Lines.Add(' Scale ' + BooleanToStr(ADocumentSummaryInformation.Scale));
  105. //ADocumentSummaryInformation.HeadingPair
  106. //ADocumentSummaryInformation.DocParts
  107. Memo1.Lines.Add(string(' Manager ' + ADocumentSummaryInformation.Manager));
  108. Memo1.Lines.Add(string(' Company ' + ADocumentSummaryInformation.Company));
  109. Memo1.Lines.Add(' Links dirty ' + BooleanToStr(ADocumentSummaryInformation.LinksDirty));
  110. finally
  111. ADocumentSummaryInformation.Free;
  112. end;
  113.  
  114. FFileSummary.GetPropertySet(TJclMediaFileSummaryInformation, AMediaFileSummaryInformation);
  115. if Assigned(AMediaFileSummaryInformation) then
  116. try
  117. Memo1.Lines.Add('Media file');
  118. Memo1.Lines.Add(' Supplier ' + AMediaFileSummaryInformation.Supplier);
  119. Memo1.Lines.Add(' Source ' + AMediaFileSummaryInformation.Source);
  120. Memo1.Lines.Add(' Sequence no ' + AMediaFileSummaryInformation.SequenceNo);
  121. Memo1.Lines.Add(' Project ' + AMediaFileSummaryInformation.Project);
  122. Memo1.Lines.Add(' Status ' + IntToStr(AMediaFileSummaryInformation.Status));
  123. Memo1.Lines.Add(' Owner ' + AMediaFileSummaryInformation.Owner);
  124. Memo1.Lines.Add(' Rating ' + AMediaFileSummaryInformation.Rating);
  125. Memo1.Lines.Add(' Production ' + FileTimeToString(AMediaFileSummaryInformation.Production));
  126. Memo1.Lines.Add(' Copyright ' + AMediaFileSummaryInformation.Copyright);
  127. finally
  128. AMediaFileSummaryInformation.Free;
  129. end;
  130.  
  131. FFileSummary.GetPropertySet(TJclMSISummaryInformation, AMSISummaryInformation);
  132. if Assigned(AMSISummaryInformation) then
  133. try
  134. Memo1.Lines.Add('MSI summary');
  135. Memo1.Lines.Add(' Version ' + IntToStr(AMSISummaryInformation.Version));
  136. Memo1.Lines.Add(' Source ' + IntToStr(AMSISummaryInformation.Source));
  137. Memo1.Lines.Add(' Restrict ' + IntToStr(AMSISummaryInformation.Restrict));
  138. finally
  139. AMSISummaryInformation.Free;
  140. end;
  141.  
  142. FFileSummary.GetPropertySet(TJclShellSummaryInformation, AFilePropertySet);
  143. if Assigned(AFilePropertySet) then
  144. try
  145. Memo1.Lines.Add('Shell summary');
  146. finally
  147. AFilePropertySet.Free;
  148. end;
  149.  
  150. FFileSummary.GetPropertySet(TJclStorageSummaryInformation, AFilePropertySet);
  151. if Assigned(AFilePropertySet) then
  152. try
  153. Memo1.Lines.Add('Storage summary');
  154. finally
  155. AFilePropertySet.Free;
  156. end;
  157.  
  158. FFileSummary.GetPropertySet(TJclImageSummaryInformation, AFilePropertySet);
  159. if Assigned(AFilePropertySet) then
  160. try
  161. Memo1.Lines.Add('Image summary');
  162. finally
  163. AFilePropertySet.Free;
  164. end;
  165.  
  166. FFileSummary.GetPropertySet(TJclDisplacedSummaryInformation, AFilePropertySet);
  167. if Assigned(AFilePropertySet) then
  168. try
  169. Memo1.Lines.Add('Displaced summary');
  170. finally
  171. AFilePropertySet.Free;
  172. end;
  173.  
  174. FFileSummary.GetPropertySet(TJclBriefCaseSummaryInformation, AFilePropertySet);
  175. if Assigned(AFilePropertySet) then
  176. try
  177. Memo1.Lines.Add('Briefcase summary');
  178. finally
  179. AFilePropertySet.Free;
  180. end;
  181.  
  182. FFileSummary.GetPropertySet(TJclMiscSummaryInformation, AFilePropertySet);
  183. if Assigned(AFilePropertySet) then
  184. try
  185. Memo1.Lines.Add('Misc summary');
  186. finally
  187. AFilePropertySet.Free;
  188. end;
  189.  
  190. FFileSummary.GetPropertySet(TJclWebViewSummaryInformation, AFilePropertySet);
  191. if Assigned(AFilePropertySet) then
  192. try
  193. Memo1.Lines.Add('Webview summary');
  194. finally
  195. AFilePropertySet.Free;
  196. end;
  197.  
  198. FFileSummary.GetPropertySet(TJclMusicSummaryInformation, AFilePropertySet);
  199. if Assigned(AFilePropertySet) then
  200. try
  201. Memo1.Lines.Add('Music summary');
  202. finally
  203. AFilePropertySet.Free;
  204. end;
  205.  
  206. FFileSummary.GetPropertySet(TJclDRMSummaryInformation, AFilePropertySet);
  207. if Assigned(AFilePropertySet) then
  208. try
  209. Memo1.Lines.Add('DRM summary');
  210. finally
  211. AFilePropertySet.Free;
  212. end;
  213.  
  214. FFileSummary.GetPropertySet(TJclVideoSummaryInformation, AVideoSummaryInformation);
  215. if Assigned(AVideoSummaryInformation) then
  216. try
  217. Memo1.Lines.Add('Video summary');
  218. Memo1.Lines.Add(' Stream name ' + AVideoSummaryInformation.StreamName);
  219. Memo1.Lines.Add(' Width ' + IntToStr(AVideoSummaryInformation.Width));
  220. Memo1.Lines.Add(' Height ' + IntToStr(AVideoSummaryInformation.Height));
  221. Memo1.Lines.Add(' Time length(ms) ' + IntToStr(AVideoSummaryInformation.TimeLength));
  222. Memo1.Lines.Add(' Frame count ' + IntToStr(AVideoSummaryInformation.FrameCount));
  223. Memo1.Lines.Add(' Frame rate ' + IntToStr(AVideoSummaryInformation.FrameRate));
  224. Memo1.Lines.Add(' Data rate ' + IntToStr(AVideoSummaryInformation.DataRate));
  225. Memo1.Lines.Add(' Sample size ' + IntToStr(AVideoSummaryInformation.SampleSize));
  226. Memo1.Lines.Add(' Compression ' + AVideoSummaryInformation.Compression);
  227. Memo1.Lines.Add(' Stream number ' + IntToStr(AVideoSummaryInformation.StreamNumber));
  228. finally
  229. AVideoSummaryInformation.Free;
  230. end;
  231.  
  232. FFileSummary.GetPropertySet(TJclAudioSummaryInformation, AAudioSummaryInformation);
  233. if Assigned(AAudioSummaryInformation) then
  234. try
  235. Memo1.Lines.Add('Audio summary');
  236. Memo1.Lines.Add(' Format ' + AAudioSummaryInformation.Format);
  237. Memo1.Lines.Add(' Time length ' + IntToStr(AAudioSummaryInformation.TimeLength));
  238. Memo1.Lines.Add(' Average data rate ' + IntToStr(AAudioSummaryInformation.AverageDataRate));
  239. Memo1.Lines.Add(' Sample rate ' + IntToStr(AAudioSummaryInformation.SampleRate));
  240. Memo1.Lines.Add(' Sample size ' + IntToStr(AAudioSummaryInformation.SampleSize));
  241. Memo1.Lines.Add(' Channel count ' + IntToStr(AAudioSummaryInformation.ChannelCount));
  242. Memo1.Lines.Add(' Stream number ' + IntToStr(AAudioSummaryInformation.StreamNumber));
  243. Memo1.Lines.Add(' Stream name ' + AAudioSummaryInformation.StreamName);
  244. Memo1.Lines.Add(' Compression ' + AAudioSummaryInformation.Compression);
  245. finally
  246. AAudioSummaryInformation.Free;
  247. end;
  248.  
  249. FFileSummary.GetPropertySet(TJclControlPanelSummaryInformation, AFilePropertySet);
  250. if Assigned(AFilePropertySet) then
  251. try
  252. Memo1.Lines.Add('Control panel summary');
  253. finally
  254. AFilePropertySet.Free;
  255. end;
  256.  
  257. FFileSummary.GetPropertySet(TJclVolumeSummaryInformation, AFilePropertySet);
  258. if Assigned(AFilePropertySet) then
  259. try
  260. Memo1.Lines.Add('Volume summary');
  261. finally
  262. AFilePropertySet.Free;
  263. end;
  264.  
  265. FFileSummary.GetPropertySet(TJclShareSummaryInformation, AFilePropertySet);
  266. if Assigned(AFilePropertySet) then
  267. try
  268. Memo1.Lines.Add('Share summary');
  269. finally
  270. AFilePropertySet.Free;
  271. end;
  272.  
  273. FFileSummary.GetPropertySet(TJclLinkSummaryInformation, AFilePropertySet);
  274. if Assigned(AFilePropertySet) then
  275. try
  276. Memo1.Lines.Add('Link summary');
  277. finally
  278. AFilePropertySet.Free;
  279. end;
  280.  
  281. FFileSummary.GetPropertySet(TJclQuerySummaryInformation, AFilePropertySet);
  282. if Assigned(AFilePropertySet) then
  283. try
  284. Memo1.Lines.Add('Query summary');
  285. finally
  286. AFilePropertySet.Free;
  287. end;
  288.  
  289. FFileSummary.GetPropertySet(TJclImageInformation, AFilePropertySet);
  290. if Assigned(AFilePropertySet) then
  291. try
  292. Memo1.Lines.Add('Image');
  293. finally
  294. AFilePropertySet.Free;
  295. end;
  296.  
  297. FFileSummary.GetPropertySet(TJclJpegSummaryInformation, AFilePropertySet);
  298. if Assigned(AFilePropertySet) then
  299. try
  300. Memo1.Lines.Add('Jpeg summary');
  301. finally
  302. AFilePropertySet.Free;
  303. end;
  304. finally
  305. FreeAndNil(FFileSummary);
  306. end;
  307.  
  308. if Memo1.Lines.Count = 0 then
  309. Memo1.Lines.Add('No properties');
  310. end;
  311.  
  312. end.
  313.