--- dao/DelphiScanner/Utils.pas 2015/08/26 19:52:38 2682
+++ dao/DelphiScanner/Utils.pas 2015/09/03 14:27:21 2693
@@ -20,6 +20,10 @@
class function TColorToHex(Color : TColor) : string;
class function HexToTColor(sColor : string) : TColor;
+ class function AdobeReaderExists(): Boolean;
+
+ class function Sto_GetFmtFileVersion(const FileName: String = ''): String;
+
@@ -31,7 +35,9 @@
Types, //TRect ,
Windows,
Messages,
- SysUtils //IntToStr etc
+ SysUtils, //IntToStr etc
+ Registry
+
;
{
@@ -161,4 +167,73 @@
end;
+class function TUtils.AdobeReaderExists(): Boolean;
+var
+ AReg: TRegistry;
+begin
+ result:= false;
+ AReg := TRegistry.Create;
+ AReg.RootKey := HKEY_LOCAL_MACHINE;
+ if AReg.KeyExists('\SOFTWARE\Adobe\Acrobat Reader') then
+ result:= True;
+ AReg.Free;
+end;
+
+
+///
+/// This function reads the file resource of "FileName" and returns
+/// the version number as formatted text.
+///
+/// Sto_GetFmtFileVersion() = '4.13.128.0'
+/// Sto_GetFmtFileVersion('', '%.2d-%.2d-%.2d') = '04-13-128'
+///
+/// If "Fmt" is invalid, the function may raise an
+/// EConvertError exception.
+/// Full path to exe or dll. If an empty
+/// string is passed, the function uses the filename of the
+/// running exe or dll.
+/// Format string, you can use at most four integer
+/// values.
+/// Formatted version number of file, '' if no version
+/// resource found.
+class function TUtils.Sto_GetFmtFileVersion(const FileName: String = ''): String;
+var
+ sFileName: String;
+ iBufferSize: DWORD;
+ iDummy: DWORD;
+ pBuffer: Pointer;
+ pFileInfo: Pointer;
+ iVer: array[1..4] of Integer;
+begin
+ // set default value
+ Result := '';
+ // get filename of exe/dll if no filename is specified
+ sFileName := Trim(FileName);
+ if (sFileName = '') then
+ sFileName := GetModuleName(HInstance);
+ // get size of version info (0 if no version info exists)
+ iBufferSize := GetFileVersionInfoSize(PChar(sFileName), iDummy);
+ if (iBufferSize > 0) then
+ begin
+ GetMem(pBuffer, iBufferSize);
+ try
+ // get fixed file info (language independent)
+ GetFileVersionInfo(PChar(sFileName), 0, iBufferSize, pBuffer);
+ VerQueryValue(pBuffer, '\', pFileInfo, iDummy);
+ // read version blocks
+ iVer[1] := HiWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionMS);
+ iVer[2] := LoWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionMS);
+ iVer[3] := HiWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionLS);
+ iVer[4] := LoWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionLS);
+ finally
+ FreeMem(pBuffer);
+ end;
+
+ // format result string
+ Result := Format('%d.%d.%d.%d', [iVer[1], iVer[2], iVer[3], iVer[4]]);
+
+ end;
+end;
+
+
end.