home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d123456 / DFS.ZIP / VersInfo.pas < prev    next >
Pascal/Delphi Source File  |  2001-06-28  |  38KB  |  1,211 lines

  1. {$I DFS.INC}  { Standard defines for all Delphi Free Stuff components }
  2.  
  3. {------------------------------------------------------------------------------}
  4. { TdfsVersionInfoResource v2.36                                                }
  5. {------------------------------------------------------------------------------}
  6. { A component to read version info resources.  It is intended for Delphi 3,    }
  7. { but should work with any file that contains a properly formatted resource.   }
  8. {                                                                              }
  9. { Copyright 2000-2001, Brad Stowers.  All Rights Reserved.                     }
  10. {                                                                              }
  11. { Copyright:                                                                   }
  12. { All Delphi Free Stuff (hereafter "DFS") source code is copyrighted by        }
  13. { Bradley D. Stowers (hereafter "author"), and shall remain the exclusive      }
  14. { property of the author.                                                      }
  15. {                                                                              }
  16. { Distribution Rights:                                                         }
  17. { You are granted a non-exlusive, royalty-free right to produce and distribute }
  18. { compiled binary files (executables, DLLs, etc.) that are built with any of   }
  19. { the DFS source code unless specifically stated otherwise.                    }
  20. { You are further granted permission to redistribute any of the DFS source     }
  21. { code in source code form, provided that the original archive as found on the }
  22. { DFS web site (http://www.delphifreestuff.com) is distributed unmodified. For }
  23. { example, if you create a descendant of TDFSColorButton, you must include in  }
  24. { the distribution package the colorbtn.zip file in the exact form that you    }
  25. { downloaded it from http://www.delphifreestuff.com/mine/files/colorbtn.zip.   }
  26. {                                                                              }
  27. { Restrictions:                                                                }
  28. { Without the express written consent of the author, you may not:              }
  29. {   * Distribute modified versions of any DFS source code by itself. You must  }
  30. {     include the original archive as you found it at the DFS site.            }
  31. {   * Sell or lease any portion of DFS source code. You are, of course, free   }
  32. {     to sell any of your own original code that works with, enhances, etc.    }
  33. {     DFS source code.                                                         }
  34. {   * Distribute DFS source code for profit.                                   }
  35. {                                                                              }
  36. { Warranty:                                                                    }
  37. { There is absolutely no warranty of any kind whatsoever with any of the DFS   }
  38. { source code (hereafter "software"). The software is provided to you "AS-IS", }
  39. { and all risks and losses associated with it's use are assumed by you. In no  }
  40. { event shall the author of the softare, Bradley D. Stowers, be held           }
  41. { accountable for any damages or losses that may occur from use or misuse of   }
  42. { the software.                                                                }
  43. {                                                                              }
  44. { Support:                                                                     }
  45. { Support is provided via the DFS Support Forum, which is a web-based message  }
  46. { system.  You can find it at http://www.delphifreestuff.com/discus/           }
  47. { All DFS source code is provided free of charge. As such, I can not guarantee }
  48. { any support whatsoever. While I do try to answer all questions that I        }
  49. { receive, and address all problems that are reported to me, you must          }
  50. { understand that I simply can not guarantee that this will always be so.      }
  51. {                                                                              }
  52. { Clarifications:                                                              }
  53. { If you need any further information, please feel free to contact me directly.}
  54. { This agreement can be found online at my site in the "Miscellaneous" section.}
  55. {------------------------------------------------------------------------------}
  56. { The lateset version of my components are always available on the web at:     }
  57. {   http://www.delphifreestuff.com/                                            }
  58. { See VersInfo.txt for notes, known issues, and revision history.              }
  59. {------------------------------------------------------------------------------}
  60. { Date last modified:  June 28, 2001                                           }
  61. {------------------------------------------------------------------------------}
  62.  
  63. unit VersInfo;
  64.  
  65. interface
  66.  
  67. uses
  68. {$IFDEF DFS_VERSION_INFO_AS_CLASS}
  69.   {$IFDEF DFS_WIN32}
  70.   Windows,
  71.   {$ELSE}
  72.   WinTypes, WinProcs, Ver,
  73.   {$ENDIF}
  74.   Classes, SysUtils;  { I really hate Forms }
  75. {$ELSE}
  76.   {$IFDEF DFS_WIN32}
  77.   Windows, ComCtrls,
  78.   {$ELSE}
  79.   WinTypes, WinProcs, Ver, Grids,
  80.   {$ENDIF}
  81.   Messages, SysUtils, Classes, Graphics, Forms, StdCtrls;
  82. {$ENDIF}
  83.  
  84.  
  85. const
  86.   { This shuts up C++Builder 3 about the redefiniton being different. There
  87.     seems to be no equivalent in C1.  Sorry. }
  88.   {$IFDEF DFS_CPPB_3_UP}
  89.   {$EXTERNALSYM DFS_COMPONENT_VERSION}
  90.   {$ENDIF}
  91.   DFS_COMPONENT_VERSION = 'TdfsVersionInfoResource v2.36';
  92.   DEFAULT_LANG_ID       = $0409;
  93.   DEFAULT_CHAR_SET_ID   = $04E4;
  94.   DEFAULT_LANG_CHAR_SET = '040904E4';
  95.  
  96.  
  97. {$IFDEF DFS_COMPILER_3_UP}
  98. resourcestring
  99. {$ELSE}
  100. const
  101. {$ENDIF}
  102.   SFlagDebug = 'Debug';
  103.   SFlagInfoInferred = 'Info Inferred';
  104.   SFlagPatched = 'Patched';
  105.   SFlagPreRelease = 'Pre-Release';
  106.   SFlagPrivate = 'Private';
  107.   SFlagSpecial = 'Special';
  108.   SHeaderResource = 'Resource';
  109.   SHeaderValue ='Value';
  110.  
  111.   { Predefined resource item captions. }  
  112.   SResCapCompanyName = 'Company Name';
  113.   SResCapFileDescription = 'File Description';
  114.   SResCapFileVersion = 'File Version';
  115.   SResCapInternalName = 'Internal Name';
  116.   SResCapLegalCopyright = 'Legal Copyright';
  117.   SResCapLegalTrademarks = 'Legal Trademarks';
  118.   SResCapOriginalFilename = 'Original Filename';
  119.   SResCapProductName = 'Product Name';
  120.   SResCapProductVersion = 'Product Version';
  121.   SResCapComments = 'Comments';
  122.   SResCapBuildFlags = 'Build Flags';
  123.  
  124.  
  125. { set values to choose which resources are seen in the grid/listview }
  126. type
  127.   TPreDef = (pdCompanyName, pdFileDescription, pdFileVersion,
  128.     pdInternalName, pdLegalCopyright, pdLegalTrademarks,
  129.     pdOriginalFilename, pdProductName, pdProductVersion,
  130.     pdComments, pdBuildFlags);
  131.   TPreDefs = set of TPreDef;
  132.  
  133. { but to index properties we need integers }
  134. const
  135.   IDX_COMPANYNAME           = ord (pdCompanyName);
  136.   IDX_FILEDESCRIPTION       = ord (pdFileDescription);
  137.   IDX_FILEVERSION           = ord (pdFileVersion);
  138.   IDX_INTERNALNAME          = ord (pdInternalName);
  139.   IDX_LEGALCOPYRIGHT        = ord (pdLegalCopyright);
  140.   IDX_LEGALTRADEMARKS       = ord (pdLegalTrademarks);
  141.   IDX_ORIGINALFILENAME      = ord (pdOriginalFilename);
  142.   IDX_PRODUCTNAME           = ord (pdProductName);
  143.   IDX_PRODUCTVERSION        = ord (pdProductVersion);
  144.   IDX_COMMENTS              = ord (pdComments);
  145.   IDX_BUILDFLAGS            = ord (pdBuildFlags);
  146.  
  147. const
  148.   IDX_VER_MAJOR   = 0;
  149.   IDX_VER_MINOR   = 1;
  150.   IDX_VER_RELEASE = 2;
  151.   IDX_VER_BUILD   = 3;
  152.  
  153. type
  154.   {$IFNDEF DFS_WIN32}
  155.   PVSFixedFileInfo = PVS_FixedFileInfo;
  156.   DWORD = longint;
  157.   UINT = word;
  158.   {$ENDIF}
  159.  
  160.  
  161.   TFixedFileInfoFlag = (ffDebug, ffInfoInferred, ffPatched, ffPreRelease,
  162.       ffPrivateBuild, ffSpecialBuild);
  163.   TFixedFileInfoFlags = set of TFixedFileInfoFlag;
  164.  
  165.   TVersionOperatingSystemFlag = (vosUnknown, vosDOS, vosOS2_16, vosOS2_32,
  166.       vosNT, vosWindows16, vosPresentationManager16, vosPresentationManager32, vosWindows32);
  167.   { This is supposed to be one of the first line, and one of the second line. }
  168.   TVersionOperatingSystemFlags = set of TVersionOperatingSystemFlag;
  169.  
  170.   TVersionFileType = (vftUnknown, vftApplication, vftDLL, vftDriver, vftFont,
  171.       vftVXD, vftStaticLib);
  172.  
  173.   TdfsVersionInfoResource = class; { forward declaration }
  174.  
  175.   TFixedFileVersionInfo = class
  176.   private
  177.     FParent: TdfsVersionInfoResource;
  178.     FData: PVSFixedFileInfo;
  179.  
  180.     function GetSignature: DWORD;
  181.     function GetStructureVersion: DWORD;
  182.     function GetFileVersionMS: DWORD;
  183.     function GetFileVersionLS: DWORD;
  184.     function GetProductVersionMS: DWORD;
  185.     function GetProductVersionLS: DWORD;
  186.     function GetValidFlags: TFixedFileInfoFlags;
  187.     function GetFlags: TFixedFileInfoFlags;
  188.     function GetFileOperatingSystem: TVersionOperatingSystemFlags;
  189.     function GetFileType: TVersionFileType;
  190.     function GetFileSubType: DWORD;
  191.     function GetCreationDate: TDateTime;
  192.   public
  193.     constructor Create(AParent: TdfsVersionInfoResource);
  194.  
  195.     property Parent: TdfsVersionInfoResource
  196.       read FParent write FParent;
  197.     property Data: PVSFixedFileInfo
  198.       read FData write FData;
  199.  
  200.     property Signature: DWORD
  201.       read GetSignature;
  202.     property StructureVersion: DWORD
  203.       read GetStructureVersion;
  204.     property FileVersionMS: DWORD
  205.       read GetFileVersionMS;
  206.     property FileVersionLS: DWORD
  207.       read GetFileVersionLS;
  208.     property ProductVersionMS: DWORD
  209.       read GetProductVersionMS;
  210.     property ProductVersionLS: DWORD
  211.       read GetProductVersionLS;
  212.     property ValidFlags: TFixedFileInfoFlags
  213.       read GetValidFlags;
  214.     property Flags: TFixedFileInfoFlags
  215.       read GetFlags;
  216.     property FileOperatingSystem: TVersionOperatingSystemFlags
  217.       read GetFileOperatingSystem;
  218.     property FileType: TVersionFileType
  219.       read GetFileType;
  220.     property FileSubType: DWORD
  221.       read GetFileSubType;
  222.     property CreationDate: TDateTime
  223.       read GetCreationDate;
  224.   end;
  225.  
  226.   TVersionNumberInformation = class
  227.   private
  228.     FValid : boolean;
  229.     FMostSignificant: DWORD;
  230.     FLeastSignificant: DWORD;
  231.     FVersionNumberString: string;
  232.  
  233.     function GetVersionNumber(Index: integer): word;
  234.     function GetVersionNumberString: string;
  235.   public
  236.     constructor Create(MSVer, LSVer: DWORD);
  237.     property Valid : boolean read FValid write FValid;
  238.     property Major: word
  239.       index IDX_VER_MAJOR
  240.       read GetVersionNumber;
  241.     property Minor: word
  242.       index IDX_VER_MINOR
  243.       read GetVersionNumber;
  244.     property Release: word
  245.       index IDX_VER_RELEASE
  246.       read GetVersionNumber;
  247.     property Build: word
  248.       index IDX_VER_BUILD
  249.       read GetVersionNumber;
  250.  
  251.     property AsString: string
  252.       read GetVersionNumberString;
  253.   end;
  254.  
  255. {$IFDEF DFS_DELPHI_1}
  256.   TVersionFilename = string;
  257. {$ELSE}
  258.   TVersionFilename = type string;
  259. {$ENDIF}
  260.  
  261.   TdfsVersionInfoResource = class{$IFNDEF DFS_VERSION_INFO_AS_CLASS}(TComponent){$ENDIF}
  262.   private
  263.     FVersionInfo: PChar;
  264.     FVersionInfoSize: DWORD;
  265.     FFilename: TVersionFilename;
  266.     FTranslationIDs: TStringList;
  267.     FTranslationIDIndex: integer;
  268.     FFixedInfo: TFixedFileVersionInfo;
  269.     FForceEXE: boolean;
  270.     FFileVersion: TVersionNumberInformation;
  271.     FProductVersion: TVersionNumberInformation;
  272. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  273.     FFileVersionLabel: TLabel;
  274.     FCopyrightLabel: TLabel;
  275.     {$IFDEF DFS_WIN32}
  276.     FVersionListView: TListView;
  277.     {$ELSE}
  278.     FVersionGrid: TStringGrid;
  279.     {$ENDIF}
  280.     FDescriptionLabel: TLabel;
  281.     FProductLabel: TLabel;
  282.     FShowResource: TPreDefs;
  283. {$ENDIF}
  284.   protected
  285.     procedure SetFilename(const Val: TVersionFilename);
  286.     procedure SetTranslationIDIndex(Val: integer);
  287.     function GetTranslationIDs: TStrings;
  288.     procedure SetForceEXE(Val: boolean);
  289. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  290.     {$IFDEF DFS_WIN32}
  291.     procedure SetVersionListView (Value: TListView);
  292.     {$ELSE}
  293.     procedure SetVersionGrid(Value: TStringGrid);
  294.     {$ENDIF}
  295.     procedure SetShowResource(Value: TPreDefs);
  296.     procedure SetFileVersionLabel(Value: TLabel);
  297.     procedure SetCopyrightLabel(Value: TLabel);
  298.     procedure SetProductLabel(Value: TLabel);
  299.     procedure SetDescriptionLabel(Value: TLabel);
  300.     function GetVersion: string;
  301.     procedure SetVersion(const Val: string);
  302. {$ENDIF}
  303.  
  304.     function GetResourceFilename: string; virtual;
  305. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  306.     procedure PopulateControls; virtual;
  307.     {$IFDEF DFS_WIN32}
  308.     procedure BuildListView; virtual;
  309.     {$ELSE}
  310.     procedure BuildGrid; virtual;
  311.     {$ENDIF}
  312.     procedure Notification(AComponent: TComponent;
  313.                      Operation: TOperation); override;
  314.     procedure Loaded; override;
  315. {$ENDIF}
  316.     function BuildFlags : string; virtual;
  317.     procedure ReadVersionInfoData; virtual;
  318.  
  319.     function GetVersionInfoString(Index: integer): string;
  320.     function GetResourceStr(Index: string): string;
  321.   public
  322. {$IFDEF DFS_VERSION_INFO_AS_CLASS}
  323.     constructor Create; virtual;
  324. {$ELSE}
  325.     constructor Create(AOwner: TComponent); override;
  326. {$ENDIF}    
  327.     destructor Destroy; override;
  328.  
  329.     property TranslationIDIndex: integer
  330.       read FTranslationIDIndex
  331.       write SetTranslationIDIndex;
  332.     property TranslationIDs: TStrings
  333.       read GetTranslationIDs;
  334.     property FixedInfo: TFixedFileVersionInfo
  335.       read FFixedInfo;
  336.     property UserResource[Index: string]: string
  337.       read GetResourceStr;
  338.  
  339.     property FileVersion: TVersionNumberInformation
  340.       read FFileVersion;
  341.     property ProductVersion: TVersionNumberInformation
  342.       read FProductVersion;
  343.   published
  344. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  345.     property Version: string
  346.        read GetVersion
  347.        write SetVersion
  348.        stored FALSE;
  349. {$ENDIF}
  350.     property Filename: TVersionFilename
  351.       read FFilename
  352.       write SetFilename;
  353.     property ForceEXE: boolean
  354.       read FForceEXE
  355.       write SetForceEXE
  356.       default FALSE;
  357.  
  358.     property CompanyName: string
  359.       index IDX_COMPANYNAME
  360.       read GetVersionInfoString;
  361.     property FileDescription: string
  362.       index IDX_FILEDESCRIPTION
  363.       read GetVersionInfoString;
  364.     property InternalName: string
  365.       index IDX_INTERNALNAME
  366.       read GetVersionInfoString;
  367.     property LegalCopyright: string
  368.       index IDX_LEGALCOPYRIGHT
  369.       read GetVersionInfoString;
  370.     property LegalTrademarks: string
  371.       index IDX_LEGALTRADEMARKS
  372.       read GetVersionInfoString;
  373.     property OriginalFilename: string
  374.       index IDX_ORIGINALFILENAME
  375.       read GetVersionInfoString;
  376.     property ProductName: string
  377.       index IDX_PRODUCTNAME
  378.       read GetVersionInfoString;
  379.     property Comments: string
  380.       index IDX_COMMENTS
  381.       read GetVersionInfoString;
  382.  
  383. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  384.     property VersionLabel: TLabel
  385.       read FFileVersionLabel
  386.       write SetFileVersionLabel;
  387.     {$IFDEF DFS_WIN32}
  388.     property VersionListView: TListView
  389.       read FVersionListView
  390.       write SetVersionListView;
  391.     {$ELSE}
  392.     property VersionGrid: TStringGrid
  393.       read FVersionGrid
  394.       write SetVersionGrid;
  395.     {$ENDIF}
  396.     property DescriptionLabel: TLabel
  397.       read FDescriptionLabel
  398.       write SetDescriptionLabel;
  399.     property CopyrightLabel: TLabel
  400.       read FCopyrightLabel
  401.       write SetCopyrightLabel;
  402.     property ProductLabel: TLabel
  403.       read FProductLabel
  404.       write SetProductLabel;
  405.     property ShowResource: TPreDefs
  406.       read FShowResource
  407.       write SetShowResource;
  408. {$ENDIF}
  409.   end;
  410.  
  411. implementation
  412.  
  413. const
  414.   PREDEF_RESOURCES: array[IDX_COMPANYNAME..IDX_BUILDFLAGS] of string = (
  415.      'CompanyName', 'FileDescription', 'FileVersion', 'InternalName',
  416.      'LegalCopyright', 'LegalTrademarks', 'OriginalFilename', 'ProductName',
  417.      'ProductVersion', 'Comments', 'BuildFlags'
  418.     );
  419.  
  420.   PREDEF_CAPTIONS: array[IDX_COMPANYNAME..IDX_BUILDFLAGS] of string = (
  421.      SResCapCompanyName, SResCapFileDescription, SResCapFileVersion,
  422.      SResCapInternalName, SResCapLegalCopyright, SResCapLegalTrademarks,
  423.      SResCapOriginalFilename, SResCapProductName, SResCapProductVersion,
  424.      SResCapComments, SResCapBuildFlags
  425.     );
  426.  
  427. {$IFDEF DFS_DELPHI_2}
  428.   {$DEFINE ST2DT_UNDEF}
  429. {$ENDIF}
  430. {$IFDEF DFS_CPPB_1}
  431.   {$DEFINE ST2DT_UNDEF}
  432. {$ENDIF}
  433.  
  434. {$IFDEF ST2DT_UNDEF}
  435. function SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;
  436. begin
  437.   with SystemTime do
  438.     Result := EncodeDate(wYear, wMonth, wDay) +
  439.       EncodeTime(wHour, wMinute, wSecond, wMilliSeconds);
  440. end;
  441. {$ENDIF}
  442.  
  443. {$IFNDEF DFS_WIN32}
  444. function IsLibrary: boolean;
  445. begin
  446.   Result := PrefixSeg = 0;
  447. end;
  448. {$ENDIF}
  449.  
  450.  
  451. constructor TFixedFileVersionInfo.Create(AParent: TdfsVersionInfoResource);
  452. begin
  453.   inherited Create;
  454.   FParent := AParent;
  455. end;
  456.  
  457. function TFixedFileVersionInfo.GetSignature: DWORD;
  458. begin
  459.   if FData = nil then
  460.     Result := 0
  461.   else
  462.     Result := FData^.dwSignature;
  463. end;
  464.  
  465. function TFixedFileVersionInfo.GetStructureVersion: DWORD;
  466. begin
  467.   if FData = nil then
  468.     Result := 0
  469.   else
  470.     Result := FData^.dwStrucVersion;
  471. end;
  472.  
  473. function TFixedFileVersionInfo.GetFileVersionMS: DWORD;
  474. begin
  475.   if FData = nil then
  476.     Result := 0
  477.   else
  478.     Result := FData^.dwFileVersionMS;
  479. end;
  480.  
  481. function TFixedFileVersionInfo.GetFileVersionLS: DWORD;
  482. begin
  483.   if FData = nil then
  484.     Result := 0
  485.   else
  486.     Result := FData^.dwFileVersionLS;
  487. end;
  488.  
  489. function TFixedFileVersionInfo.GetProductVersionMS: DWORD;
  490. begin
  491.   if FData = nil then
  492.     Result := 0
  493.   else
  494.     Result := FData^.dwProductVersionMS;
  495. end;
  496.  
  497. function TFixedFileVersionInfo.GetProductVersionLS: DWORD;
  498. begin
  499.   if FData = nil then
  500.     Result := 0
  501.   else
  502.     Result := FData^.dwProductVersionLS;
  503. end;
  504.  
  505. function TFixedFileVersionInfo.GetValidFlags: TFixedFileInfoFlags;
  506. begin
  507.   Result := [];
  508.   if FData <> nil then
  509.   begin
  510.     if (FData^.dwFileFlagsMask and VS_FF_DEBUG) <> 0 then
  511.       Include(Result, ffDebug);
  512.     if (FData^.dwFileFlagsMask and VS_FF_PRERELEASE) <> 0 then
  513.       Include(Result, ffPreRelease);
  514.     if (FData^.dwFileFlagsMask and VS_FF_PATCHED) <> 0 then
  515.       Include(Result, ffPatched);
  516.     if (FData^.dwFileFlagsMask and VS_FF_PRIVATEBUILD) <> 0 then
  517.       Include(Result, ffPrivateBuild);
  518.     if (FData^.dwFileFlagsMask and VS_FF_INFOINFERRED ) <> 0 then
  519.       Include(Result, ffInfoInferred );
  520.     if (FData^.dwFileFlagsMask and VS_FF_SPECIALBUILD ) <> 0 then
  521.       Include(Result, ffSpecialBuild );
  522.   end;
  523. end;
  524.  
  525. function TFixedFileVersionInfo.GetFlags: TFixedFileInfoFlags;
  526. begin
  527.   Result := [];
  528.   if FData <> nil then
  529.   begin
  530.     if (FData^.dwFileFlags and VS_FF_DEBUG) <> 0 then
  531.       Include(Result, ffDebug);
  532.     if (FData^.dwFileFlags and VS_FF_PRERELEASE) <> 0 then
  533.       Include(Result, ffPreRelease);
  534.     if (FData^.dwFileFlags and VS_FF_PATCHED) <> 0 then
  535.       Include(Result, ffPatched);
  536.     if (FData^.dwFileFlags and VS_FF_PRIVATEBUILD) <> 0 then
  537.       Include(Result, ffPrivateBuild);
  538.     if (FData^.dwFileFlags and VS_FF_INFOINFERRED ) <> 0 then
  539.       Include(Result, ffInfoInferred );
  540.     if (FData^.dwFileFlags and VS_FF_SPECIALBUILD ) <> 0 then
  541.       Include(Result, ffSpecialBuild );
  542.   end;
  543. end;
  544.  
  545. function TFixedFileVersionInfo.GetFileOperatingSystem: TVersionOperatingSystemFlags;
  546. {$IFNDEF DFS_WIN32}
  547. var
  548.   FileOS: word;
  549. {$ENDIF}
  550. begin
  551.   Result := [];
  552.   if FData <> nil then
  553.   begin
  554.     case HiWord(FData^.dwFileOS) of
  555.       VOS_DOS shr 16:   Include(Result, vosDOS);
  556.       VOS_OS216 shr 16: Include(Result, vosOS2_16);
  557.       VOS_OS232 shr 16: Include(Result, vosOS2_32);
  558.       VOS_NT shr 16:    Include(Result, vosNT);
  559.     else
  560.       Include(Result, vosUnknown);
  561.     end;
  562.  
  563. {$IFDEF DFS_WIN32}
  564.     case LoWord(FData^.dwFileOS) of
  565.       LoWord(VOS__WINDOWS16): Include(Result, vosWindows16);
  566.       LoWord(VOS__PM16):      Include(Result, vosPresentationManager16);
  567.       LoWord(VOS__PM32):      Include(Result, vosPresentationManager32);
  568.       LoWord(VOS__WINDOWS32): Include(Result, vosWindows32);
  569.     else
  570.       Include(Result, vosUnknown);
  571.     end;
  572. {$ELSE}
  573.     FileOS := LoWord(FData^.dwFileOS);
  574.     if      FileOS = LoWord(VOS__WINDOWS16) then Include(Result, vosWindows16)
  575.     else if FileOS = LoWord(VOS__PM16) then      Include(Result, vosPresentationManager16)
  576.     else if FileOS = LoWord(VOS__PM32) then      Include(Result, vosPresentationManager32)
  577.     else if FileOS = LoWord(VOS__WINDOWS32) then Include(Result, vosWindows32)
  578.     else                                         Include(Result, vosUnknown);
  579. {$ENDIF}
  580.   end;
  581. end;
  582.  
  583. function TFixedFileVersionInfo.GetFileType: TVersionFileType;
  584. begin
  585.   Result := vftUnknown;
  586.   if FData <> nil then
  587.   begin
  588.     case FData^.dwFileType of
  589.       VFT_APP:        Result := vftApplication;
  590.       VFT_DLL:        Result := vftDLL;
  591.       VFT_DRV:        Result := vftDriver;
  592.       VFT_FONT:       Result := vftFont;
  593.       VFT_VXD:        Result := vftVXD;
  594.       VFT_STATIC_LIB: Result := vftStaticLib;
  595.     end;
  596.   end;
  597. end;
  598.  
  599. function TFixedFileVersionInfo.GetFileSubType: DWORD;
  600. begin
  601.   if FData = nil then
  602.     Result := 0
  603.   else begin
  604.     Result := FData^.dwFileSubtype;
  605.   end;
  606. end;
  607.  
  608. function TFixedFileVersionInfo.GetCreationDate: TDateTime;
  609. {$IFDEF DFS_WIN32}
  610. var
  611.   SysTime: TSystemTime;
  612.   FileTime: TFileTime;
  613. begin
  614.   if FData = nil then
  615.     Result := 0
  616.   else begin
  617.     FileTime.dwLowDateTime := FData^.dwFileDateLS;
  618.     FileTime.dwHighDateTime := FData^.dwFileDateMS;
  619.     if FileTimeToSystemTime(FileTime, SysTime) then
  620.     begin
  621.       Result := SystemTimeToDateTime(SysTime);
  622.     end else
  623.       Result := 0;
  624.   end;
  625. {$ELSE}
  626. var
  627.   SR: TSearchRec;
  628. begin
  629.   { Fake it until I can figure out how to convert dwFileDateMS and LS }
  630.   Result := 0;
  631.   if assigned(FParent) then
  632.   begin
  633.     if FindFirst(FParent.GetResourceFilename, faAnyFile, SR) = 0 then
  634.     begin
  635.       Result := FileDateToDateTime(SR.Time);
  636.       FindClose(SR);
  637.     end;
  638.   end;
  639. (*
  640. var
  641.   BigNum: comp;
  642. begin
  643.   if FData = nil then
  644.     Result := 0
  645.   else begin
  646.  
  647.     BigNum := (FData^.dwFileDateMS * MaxLongInt) + FData^.dwFileDateLS;
  648.     BigNum := BigNum / 10000000;
  649.   { LS and MS is the number of 100 nanosecond intervals since 1/1/1601 }
  650.   { 10,000,000s of a second }
  651.     Result := EncodeDate(1601, 1, 1);
  652.     Result := BigNum.....
  653.   end;
  654. *)
  655.  
  656. {$ENDIF}
  657. end;
  658.  
  659.  
  660.  
  661. constructor TVersionNumberInformation.Create(MSVer, LSVer: DWORD);
  662. begin
  663.   inherited Create;
  664.  
  665.   FValid := false;
  666.   FMostSignificant := MSVer;
  667.   FLeastSignificant := LSVer;
  668. end;
  669.  
  670. function TVersionNumberInformation.GetVersionNumber(Index: integer): word;
  671. begin
  672.   Result := 0;
  673.   if FValid then
  674.     case Index of
  675.       IDX_VER_MAJOR:   Result := HiWord(FMostSignificant);
  676.       IDX_VER_MINOR:   Result := LoWord(FMostSignificant);
  677.       IDX_VER_RELEASE: Result := HiWord(FLeastSignificant);
  678.       IDX_VER_BUILD:   Result := LoWord(FLeastSignificant)
  679.     end
  680. end;
  681.  
  682. function TVersionNumberInformation.GetVersionNumberString: string;
  683. begin
  684.   if FValid then
  685.   begin
  686.     if FVersionNumberString = '' then
  687.       Result := Format('%d.%d.%d.%d', [Major, Minor, Release, Build])
  688.     else
  689.       Result := FVersionNumberString;
  690.   end
  691.   else
  692.     Result := ''
  693. end;
  694.  
  695.  
  696.  
  697. {$IFDEF DFS_VERSION_INFO_AS_CLASS}
  698. constructor TdfsVersionInfoResource.Create;
  699. begin
  700.   inherited Create;
  701.  
  702.   FVersionInfo := nil;
  703.   FVersionInfoSize := 0;
  704.   FFilename := '';
  705.   FTranslationIDIndex := 0;
  706.   FForceEXE := FALSE;
  707.   FTranslationIDs := TStringList.Create;
  708.   FFileVersion := TVersionNumberInformation.Create(0, 0);
  709.   FProductVersion := TVersionNumberInformation.Create(0, 0);
  710.   FFixedInfo := TFixedFileVersionInfo.Create(Self);
  711. end;
  712. {$ELSE}
  713. constructor TdfsVersionInfoResource.Create(AOwner: TComponent);
  714. begin
  715.   inherited Create(AOwner);
  716.  
  717.   FVersionInfo := nil;
  718.   FVersionInfoSize := 0;
  719.   FFilename := '';
  720.   FTranslationIDIndex := 0;
  721.   FForceEXE := FALSE;
  722.   FTranslationIDs := TStringList.Create;
  723.   FFileVersion := TVersionNumberInformation.Create(0, 0);
  724.   FProductVersion := TVersionNumberInformation.Create(0, 0);
  725.   FFixedInfo := TFixedFileVersionInfo.Create(Self);
  726.   FShowResource := [Low(TPreDef)..High(TPreDef)]
  727. end;
  728. {$ENDIF}
  729.  
  730. destructor TdfsVersionInfoResource.Destroy;
  731. begin
  732.   FFileVersion.Free;
  733.   FProductVersion.Free;
  734.   FFixedInfo.Free;
  735.   FTranslationIDs.Free;
  736.   if FVersionInfo <> nil then
  737.     FreeMem(FVersionInfo, FVersionInfoSize);
  738.  
  739.   inherited Destroy;
  740. end;
  741.  
  742. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  743. procedure TdfsVersionInfoResource.Loaded;
  744. begin
  745.   inherited Loaded;
  746.  
  747.   ReadVersionInfoData;
  748. (*
  749. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  750.   PopulateControls;
  751. {$ENDIF}
  752. *)
  753. end;
  754. {$ENDIF}
  755.  
  756. procedure TdfsVersionInfoResource.SetFilename(const Val: TVersionFilename);
  757. begin
  758.   FFilename := Val;
  759.   ReadVersionInfoData;
  760. end;
  761.  
  762. procedure TdfsVersionInfoResource.ReadVersionInfoData;
  763. const
  764.   TRANSLATION_INFO = '\VarFileInfo\Translation';
  765. type
  766.   TTranslationPair = packed record
  767.     Lang,
  768.     CharSet: word;
  769.   end;
  770.   PTranslationIDList = ^TTranslationIDList;
  771.   TTranslationIDList = array[0..MAXINT div SizeOf(TTranslationPair)-1] of TTranslationPair;
  772. var
  773.   QueryLen: UINT;
  774.   IDsLen: UINT;
  775.   Dummy: DWORD;
  776.   IDs: PTranslationIDList;
  777.   IDCount: integer;
  778.   FixedInfoData: PVSFixedFileInfo;
  779.   TempFilename: array[0..255] of char;
  780. begin
  781.   FTranslationIDs.Clear;
  782.   FFixedInfo.Data := nil;
  783.   if FVersionInfo <> nil then
  784.     FreeMem(FVersionInfo, FVersionInfoSize);
  785.   StrPCopy(TempFileName, GetResourceFilename);
  786.  
  787.   { Denis Kopprasch: added a try-Except because GetFileVersionInfoSize can fail
  788.     with an invalid pointer or something like that! }
  789.   try
  790.     FVersionInfoSize := GetFileVersionInfoSize(TempFileName, Dummy);
  791.   except
  792.     FVersionInfoSize := 0;
  793.   end;
  794.  
  795.   if FVersionInfoSize = 0 then
  796.   begin
  797.     FVersionInfo := nil;
  798.     FFileVersion.Valid := false;
  799.     FProductVersion.Valid := false;
  800.   end else begin
  801.     GetMem(FVersionInfo, FVersionInfoSize);
  802.     GetFileVersionInfo(TempFileName, Dummy, FVersionInfoSize, FVersionInfo);
  803.  
  804.     VerQueryValue(FVersionInfo, '\', pointer(FixedInfoData), QueryLen);
  805.     FFixedInfo.Data := FixedInfoData;
  806.     if VerQueryValue(FVersionInfo, TRANSLATION_INFO, Pointer(IDs), IDsLen) then
  807.     begin
  808.       { Denis Kopprasch: if IDCount = 0, the for .. to ...-Statement is executed
  809.         several times (maybe infinite until error) if range checking off }
  810.       IDCount := IDsLen div SizeOf(TTranslationPair);
  811.       if (IDCount > 0) then
  812.       begin
  813.         for Dummy := 0 to IDCount-1 do
  814.         begin
  815.   {!!! Potential problem.  Some of MS's stuff does this, some does not.  Need to
  816.        figure a way to make it work with both.}
  817. (*          if IDs^[Dummy].Lang = 0 then
  818.             IDs^[Dummy].Lang := DEFAULT_LANG_ID; { Some of Microsoft's stuff does this }
  819.           if IDs^[Dummy].CharSet = 0 then
  820.             IDs^[Dummy].CharSet := DEFAULT_CHAR_SET_ID;*)
  821.           FTranslationIDs.Add(Format('%.4x%.4x', [IDs^[Dummy].Lang, IDs^[Dummy].CharSet]));
  822.         end;
  823.       end
  824.       else
  825.       if (IDCount = 0) and (IDsLen > 0) then
  826.       begin
  827.         { There was translation info, but there was not a full set.  What's
  828.           there is usually a char set, so we have to swap things around. }
  829.         FTranslationIDs.Add(Format('%.4x%.4x', [DEFAULT_LANG_ID, IDs^[Dummy].Lang]));
  830.       end;
  831.     end;
  832.  
  833.     if FTranslationIDIndex >= FTranslationIDs.Count then
  834.       FTranslationIDIndex := 0;
  835.  
  836.     FFileVersion.Valid := true;
  837.     FFileVersion.FMostSignificant := FFixedInfo.GetFileVersionMS;
  838.     FFileVersion.FLeastSignificant := FFixedInfo.GetFileVersionLS;
  839.     FFileVersion.FVersionNumberString := GetVersionInfoString(IDX_FILEVERSION);
  840.     FProductVersion.Valid := true;
  841.     FProductVersion.FMostSignificant := FFixedInfo.GetProductVersionMS;
  842.     FProductVersion.FLeastSignificant := FFixedInfo.GetProductVersionLS;
  843.     FProductVersion.FVersionNumberString := GetVersionInfoString(
  844.       IDX_PRODUCTVERSION);
  845.   end;
  846. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  847.   PopulateControls;
  848. {$ENDIF}
  849. end;
  850.  
  851. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  852. procedure TdfsVersionInfoResource.PopulateControls;
  853. begin
  854.   if [csDesigning, csLoading] * ComponentState <> [] then exit;
  855.   
  856.   if assigned(FFileVersionLabel) then
  857.     FFileVersionLabel.Caption := FileVersion.AsString;
  858.   if assigned(FCopyrightLabel) then
  859.     FCopyrightLabel.Caption := LegalCopyright;
  860.   if assigned(FProductLabel) then
  861.     FProductLabel.Caption := ProductName;
  862.   if assigned(FDescriptionLabel) then
  863.     FDescriptionLabel.Caption := FileDescription;
  864. {$IFDEF DFS_WIN32}
  865.   if Assigned (FVersionListView) then
  866.     BuildListView;
  867. {$ELSE}
  868.   if assigned(FVersionGrid) then
  869.     BuildGrid;
  870. {$ENDIF}
  871. end;
  872. {$ENDIF}
  873.  
  874. function TdfsVersionInfoResource.GetResourceFilename: string;
  875. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  876. var
  877.   TempFilename: array[0..255] of char;
  878. {$ENDIF}
  879. begin
  880.   {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  881.   if FFilename = '' then
  882.   begin
  883.     if IsLibrary and (not FForceEXE) then
  884.     begin
  885.       GetModuleFileName(HInstance, TempFileName, SizeOf(TempFileName)-1);
  886.       Result := StrPas(TempFileName);
  887.     end else
  888.       Result := Application.EXEName;
  889.   end else
  890.   {$ENDIF}
  891.     Result := FFilename;
  892. end;
  893.  
  894.  
  895. function TdfsVersionInfoResource.GetVersionInfoString(Index: integer): string;
  896. begin
  897.   if (Index >= Low(PREDEF_RESOURCES)) and (Index <= High(PREDEF_RESOURCES)) then
  898.     Result := GetResourceStr(PREDEF_RESOURCES[Index])
  899.   else
  900.     Result := ''
  901. end;
  902.  
  903.  
  904. function TdfsVersionInfoResource.GetResourceStr(Index: string): string;
  905. var
  906.   ResStr: PChar;
  907.   StrLen: UINT;
  908.   SubBlock: array[0..255] of char;
  909.   LangCharSet: string;
  910. begin
  911.   if FTranslationIDIndex < FTranslationIDs.Count then
  912.     LangCharSet := FTranslationIDs[FTranslationIDIndex]
  913.   else
  914.     LangCharSet := DEFAULT_LANG_CHAR_SET;
  915.   StrPCopy(SubBlock, '\StringFileInfo\' + LangCharSet + '\' + Index);
  916.   if (FVersionInfo <> nil) and
  917.      VerQueryValue(FVersionInfo, SubBlock, Pointer(ResStr), StrLen)
  918.   then
  919.     Result := StrPas(ResStr)
  920.   else
  921.     Result := '';
  922. end;
  923.  
  924.  
  925. procedure TdfsVersionInfoResource.SetTranslationIDIndex(Val: integer);
  926. begin
  927.   if (Val > 0) and (Val < FTranslationIDs.Count) then
  928.     FTranslationIDIndex := Val;
  929. end;
  930.  
  931.  
  932. function TdfsVersionInfoResource.GetTranslationIDs: TStrings;
  933. begin
  934.   Result := FTranslationIDs;
  935. end;
  936.  
  937.  
  938. procedure TdfsVersionInfoResource.SetForceEXE(Val: boolean);
  939. begin
  940.   if FForceEXE <> Val then
  941.   begin
  942.     FForceEXE := Val;
  943.     ReadVersionInfoData;
  944.   end;
  945. end;
  946.  
  947.  
  948. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  949. procedure TdfsVersionInfoResource.SetFileVersionLabel(Value: TLabel);
  950. begin
  951.   FFileVersionLabel := Value;
  952.   if assigned(FFileVersionLabel) then
  953.   begin
  954. {$IFDEF DFS_WIN32}
  955.     FFileVersionLabel.FreeNotification(Self);
  956. {$ENDIF}
  957.     FShowResource := FShowResource - [pdFileVersion];
  958.     PopulateControls;
  959.   end;
  960. end;
  961.  
  962. procedure TdfsVersionInfoResource.SetCopyrightLabel(Value: TLabel);
  963. begin
  964.   FCopyrightLabel := Value;
  965.   if assigned(FCopyrightLabel) then
  966.   begin
  967. {$IFDEF DFS_WIN32}
  968.     FCopyrightLabel.FreeNotification(Self);
  969. {$ENDIF}
  970.     FShowResource := FShowResource - [pdLegalCopyright];
  971.     PopulateControls;
  972.   end;
  973. end;
  974.  
  975. procedure TdfsVersionInfoResource.SetProductLabel(Value: TLabel);
  976. begin
  977.   FProductLabel := Value;
  978.   if assigned(FProductLabel) then
  979.   begin
  980. {$IFDEF DFS_WIN32}
  981.     FProductLabel.FreeNotification(Self);
  982. {$ENDIF}
  983.     FShowResource := FShowResource - [pdProductName];
  984.     PopulateControls;
  985.   end;
  986. end;
  987.  
  988. procedure TdfsVersionInfoResource.SetDescriptionLabel(Value: TLabel);
  989. begin
  990.   FDescriptionLabel := Value;
  991.   if assigned(FDescriptionLabel) then
  992.   begin
  993. {$IFDEF DFS_WIN32}
  994.     FDescriptionLabel.FreeNotification(Self);
  995. {$ENDIF}
  996.     FShowResource := FShowResource - [pdFileDescription];
  997.     PopulateControls;
  998.   end;
  999. end;
  1000.  
  1001. procedure TdfsVersionInfoResource.SetShowResource(Value: TPreDefs);
  1002. begin
  1003.   if Value <> FShowResource then
  1004.   begin
  1005.     FShowResource:= Value;
  1006.     PopulateControls;
  1007.   end
  1008. end;
  1009.  
  1010. {$IFDEF DFS_WIN32}
  1011. procedure TdfsVersionInfoResource.SetVersionListView (Value: TListView);
  1012. begin
  1013.   FVersionListView := Value;
  1014.   if Assigned(FVersionListView) then
  1015.   begin
  1016.     FVersionListView.FreeNotification(Self);
  1017.     PopulateControls;
  1018.   end;
  1019. end;
  1020.  
  1021. {$ELSE}
  1022.  
  1023. procedure TdfsVersionInfoResource.SetVersionGrid(Value: TStringGrid);
  1024. begin
  1025.   FVersionGrid := Value;
  1026.   if Assigned(FVersionGrid) then
  1027.   begin
  1028. {$IFDEF DFS_WIN32}
  1029.     FVersionGrid.FreeNotification(Self);
  1030. {$ENDIF}
  1031.     PopulateControls;
  1032.   end;
  1033. end;
  1034. {$ENDIF}
  1035.  
  1036.  
  1037. procedure TdfsVersionInfoResource.Notification(AComponent: TComponent;
  1038.    Operation: TOperation);
  1039. begin
  1040.   inherited Notification(AComponent, Operation);
  1041.   if Operation = opRemove then
  1042.   begin
  1043.     if (AComponent = FFileVersionLabel) then
  1044.       FFileVersionLabel := nil
  1045.     else if (AComponent = FCopyrightLabel) then
  1046.       FCopyRightLabel := nil
  1047.     else if (AComponent = FProductLabel) then
  1048.       FProductLabel := nil
  1049.     else if (AComponent = FDescriptionLabel) then
  1050.       FDescriptionLabel := nil
  1051. {$IFDEF DFS_WIN32}
  1052.     else if (AComponent = FVersionListView) then
  1053.       FVersionListView := nil;
  1054. {$ELSE}
  1055.     else if (AComponent = FVersionGrid) then
  1056.       FVersionGrid := nil;
  1057. {$ENDIF}
  1058.   end;
  1059. end;
  1060. {$ENDIF}
  1061.  
  1062. function TdfsVersionInfoResource.BuildFlags : string;
  1063. const
  1064.   FLAG_STRING: array[TFixedFileInfoFlag] of string = (
  1065.       SFlagDebug, SFlagInfoInferred, SFlagPatched, SFlagPreRelease,
  1066.       SFlagPrivate, SFlagSpecial
  1067.     );
  1068. var
  1069.   AFlag: TFixedFileInfoFlag;
  1070. begin
  1071.   Result := '';
  1072.   for AFlag := Low(TFixedFileInfoFlag) to High(TFixedFileInfoFlag) do
  1073.     if AFlag in FixedInfo.Flags then
  1074.       Result := Result + FLAG_STRING[AFlag] + ', ';
  1075.  
  1076.   if Length(Result) > 0 then
  1077.     Result := Copy(Result, 1, Length(Result)-2);
  1078. end;
  1079.  
  1080. {$IFNDEF DFS_VERSION_INFO_AS_CLASS}
  1081. {$IFDEF DFS_WIN32}
  1082. procedure TdfsVersionInfoResource.BuildListView;
  1083.  
  1084.   procedure Add_Item (StrId: integer; const Str: string);
  1085.   var
  1086.     NewItem : TListItem;
  1087.   begin
  1088.     if (Str <> '') and (TPreDef(StrId) in FShowResource) then
  1089.     begin
  1090.       NewItem := VersionListView.Items.Add;
  1091.       NewItem.Caption := PREDEF_CAPTIONS[StrId];
  1092.       NewItem.SubItems.Add (Str)
  1093.     end
  1094.   end;
  1095.  
  1096.   procedure Add_Column (const Str: string);
  1097.   var
  1098.     NewColumn : TListColumn;
  1099.   begin
  1100.     NewColumn := VersionListView.Columns.Add;
  1101.     NewColumn.Caption := Str;
  1102.     NewColumn.Width := -2; { nifty! }
  1103.   end;
  1104.  
  1105. begin
  1106.   if Assigned (VersionListView) then
  1107.   with VersionListView do
  1108.   begin
  1109.     Columns.Clear;
  1110.     Items.Clear;
  1111.  
  1112. { only the minimum parameters in the listview are forced: }
  1113.     ViewStyle := vsReport;
  1114.     ReadOnly := true;
  1115.     ColumnClick := false;
  1116.     Add_Column (SHeaderResource);
  1117.     Add_Column (SHeaderValue);
  1118.  
  1119.     Add_Item (IDX_PRODUCTNAME, ProductName);
  1120.     Add_Item (IDX_PRODUCTVERSION, ProductVersion.AsString);
  1121.     Add_Item (IDX_COMPANYNAME, CompanyName);
  1122.     Add_Item (IDX_LEGALCOPYRIGHT, LegalCopyright);
  1123.     Add_Item (IDX_LEGALTRADEMARKS, LegalTrademarks);
  1124.     Add_Item (IDX_FILEDESCRIPTION, FileDescription);
  1125.     Add_Item (IDX_FILEVERSION, FileVersion.AsString);
  1126.     Add_Item (IDX_INTERNALNAME, InternalName);
  1127.     Add_Item (IDX_ORIGINALFILENAME, OriginalFilename);
  1128.     Add_Item (IDX_BUILDFLAGS, BuildFlags);
  1129.     Add_Item (IDX_COMMENTS, Comments);
  1130.   end
  1131. end;
  1132.  
  1133. {$ELSE}
  1134.  
  1135. procedure TdfsVersionInfoResource.BuildGrid;
  1136. const
  1137.   FLAG_STRING: array[TFixedFileInfoFlag] of string = (
  1138.       SFlagDebug, SFlagInfoInferred, SFlagPatched, SFlagPreRelease,
  1139.       SFlagPrivate, SFlagSpecial
  1140.     );
  1141.  
  1142.   procedure AddGridRow(var RowNum: integer; StrID: integer; Str: string);
  1143.   var
  1144.     i: integer;
  1145.   begin
  1146.     if (Str <> '') and (TPreDef(StrId) in FShowResource) then
  1147.     begin
  1148.       with VersionGrid do
  1149.       begin
  1150.         Cells[0,RowNum] := PREDEF_CAPTIONS[StrID];
  1151.         Cells[1,RowNum] := Str;
  1152.         i := Canvas.TextWidth(Str);
  1153.         if i > ColWidths[1] then
  1154.           ColWidths[1] := i + 4;
  1155.         inc(RowNum);
  1156.       end;
  1157.     end;
  1158.   end;
  1159.  
  1160. var
  1161.   i, FRow: Integer;
  1162.  
  1163. begin
  1164.   With VersionGrid do
  1165.   begin
  1166.     { Set Defaults }
  1167.     FixedCols := 0;
  1168.     FixedRows := 0;
  1169.     ColCount := 2;
  1170.     RowCount := 10;
  1171.     Canvas.Font.Assign(Font);
  1172.     DefaultRowHeight := Canvas.TextHeight(PREDEF_CAPTIONS[IDX_ORIGINALFILENAME]) + 2;
  1173.     ColWidths[0] := Canvas.TextWidth(PREDEF_CAPTIONS[IDX_LEGALTRADEMARKS]) + 4;
  1174.     ColWidths[1] := ClientWidth - COlWidths[0] - 1;
  1175.     { Clear }
  1176.     for i:= 0 to (ColCount-1) do
  1177.       Cols[i].Clear;
  1178.  
  1179.     FRow := 0;
  1180.     AddGridRow(FRow, IDX_PRODUCTNAME, ProductName);
  1181.     AddGridRow(FRow, IDX_PRODUCTVERSION, ProductVersion.AsString);
  1182.     AddGridRow(FRow, IDX_COMPANYNAME, CompanyName);
  1183.     AddGridRow(FRow, IDX_LEGALCOPYRIGHT, LegalCopyright);
  1184.     AddGridRow(FRow, IDX_LEGALTRADEMARKS, LegalTrademarks);
  1185.     AddGridRow(FRow, IDX_FILEDESCRIPTION, FileDescription);
  1186.     AddGridRow(FRow, IDX_FILEVERSION, FileVersion.AsString);
  1187.     AddGridRow(FRow, IDX_INTERNALNAME, InternalName);
  1188.     AddGridRow(FRow, IDX_ORIGINALFILENAME, OriginalFilename);
  1189.     AddGridRow(FRow, IDX_BUILDFLAGS, BuildFlags);
  1190.     AddGridRow(FRow, IDX_COMMENTS, Comments);
  1191.     RowCount := FRow;
  1192.   end;
  1193. end;
  1194. {$ENDIF}
  1195.  
  1196. function TdfsVersionInfoResource.GetVersion: string;
  1197. begin
  1198.   Result := DFS_COMPONENT_VERSION;
  1199. end;
  1200.  
  1201. procedure TdfsVersionInfoResource.SetVersion(const Val: string);
  1202. begin
  1203.   { empty write method, just needed to get it to show up in Object Inspector }
  1204. end;
  1205. {$ENDIF}
  1206.  
  1207.  
  1208. end.
  1209.  
  1210.  
  1211.