showver.pp 787 B

123456789101112131415161718192021222324252627282930313233343536
  1. program showversion;
  2. {$mode fpc}
  3. {$R showver.res}
  4. uses sysutils,fileinfo;
  5. Var version : TFileVersionInfo;
  6. I : longint;
  7. begin
  8. if Paramcount<1 then
  9. begin
  10. Writeln('Usage: showver <exefile>');
  11. halt(1);
  12. end;
  13. Version:=TFileVErsionInfo.create(Nil);
  14. Version.FileName:=paramstr(1);
  15. With Version do
  16. begin
  17. if Not FileExists(Paramstr(1)) then
  18. begin
  19. Writeln (Format('%s : No such file or directory',[Paramstr(1)]));
  20. Halt(1);
  21. end;
  22. FileName:=Paramstr(1);
  23. If VersionStrings.Count=0 then
  24. begin
  25. Writeln (Format('%s : No version information found.',[paramstr(1)]));
  26. Halt(2);
  27. end;
  28. For i:=0 to VersionStrings.Count-1 do
  29. Writeln (VersionCategories[I],'=',VersionStrings[i]);
  30. free;
  31. end;
  32. end.