Ignore:
Timestamp:
Jul 7, 2010, 4:31:10 PM (14 years ago)
Author:
Kevin Toppenberg
Message:

Upgrade to version 27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Lib/ORSystem.pas

    r456 r829  
    22
    33{$O-}
     4{$WARN SYMBOL_PLATFORM OFF}
    45
    56interface
     
    1920  CPRS_LAST_DATE = 'Software\Vista\CPRS\DateUpdated';
    2021
    21   { values that can be passed to FileVersionValue }
    22   FILE_VER_COMPANYNAME      = '\StringFileInfo\040904E4\CompanyName';
    23   FILE_VER_FILEDESCRIPTION  = '\StringFileInfo\040904E4\FileDescription';
    24   FILE_VER_FILEVERSION      = '\StringFileInfo\040904E4\FileVersion';
    25   FILE_VER_INTERNALNAME     = '\StringFileInfo\040904E4\InternalName';
    26   FILE_VER_LEGALCOPYRIGHT   = '\StringFileInfo\040904E4\LegalCopyright';
    27   FILE_VER_ORIGINALFILENAME = '\StringFileInfo\040904E4\OriginalFilename';
    28   FILE_VER_PRODUCTNAME      = '\StringFileInfo\040904E4\ProductName';
    29   FILE_VER_PRODUCTVERSION   = '\StringFileInfo\040904E4\ProductVersion';
    30   FILE_VER_COMMENTS         = '\StringFileInfo\040904E4\Comments';
    31 
    32 
    3322function AppOutOfDate(AppName: string): Boolean;
    3423function ClientVersion(const AFileName: string): string;
     
    4029//procedure FileCopy(const FromFileName, ToFileName: string);
    4130//procedure FileCopyWithDate(const FromFileName, ToFileName: string);
    42 function FileVersionValue(const AFileName, AValueName: string): string;
    4331function FullToFilePart(const AFileName: string): string;
    4432function FullToPathPart(const AFileName: string): string;
     
    6048procedure RunProgram(const AppName: string);
    6149function UpdateSelf: Boolean;
     50function BorlandDLLVersionOK: boolean;
    6251
    6352implementation
     
    11099  // check for different file date in the gold directory
    111100  GoldName := RegReadStr(CPRS_REG_GOLD);
    112   if Length(GoldName) = 0 then Exit;
     101  if (Length(GoldName) = 0)  then exit;
     102  if not DirectoryExists(GoldName) then
     103  begin
     104    if Pos('"', Goldname) > 0 then
     105    begin
     106      Goldname := Copy(GoldName, 2, MaxInt);
     107      if Pos('"', Goldname) > 0 then
     108        Goldname := Copy(GoldName, 1, Length(GoldName) - 1);
     109    end;
     110  end;
     111  if (not DirectoryExists(GoldName)) then Exit;
    113112  GoldName := GoldName + FullToFilePart(AppName);
    114113  if FileExists(GoldName) then
     
    139138                                                     IntToStr(HIWORD(dwFileVersionLS)) + '.' +
    140139                                                     IntToStr(LOWORD(dwFileVersionLS));
    141   end;
    142 end;
    143 
    144 function FileVersionValue(const AFileName, AValueName: string): string;
    145 type
    146   PValBuf = ^TValBuf;
    147   TValBuf = array[0..255] of Char;
    148 var
    149   VerSize, ValSize, AHandle: DWORD;
    150   VerBuf: Pointer;
    151   ValBuf: PValBuf;
    152 begin
    153   Result := '';
    154   VerSize:=GetFileVersionInfoSize(PChar(AFileName), AHandle);
    155   if VerSize > 0 then
    156   begin
    157     GetMem(VerBuf, VerSize);
    158     try
    159       GetFileVersionInfo(PChar(AFileName), AHandle, VerSize, VerBuf);
    160       VerQueryValue(VerBuf, PChar(AValueName), Pointer(ValBuf), ValSize);
    161       SetString(Result, ValBuf^, ValSize);
    162     finally
    163       FreeMem(VerBuf);
    164     end;
    165140  end;
    166141end;
     
    551526*)
    552527
     528function BorlandDLLVersionOK: boolean;
     529const
     530  DLL_CURRENT_VERSION = 10;
     531  TC_DLL_ERR   = 'ERROR - BORLNDMM.DLL';
     532  TX_NO_RUN    = 'This version of CPRS is unable to run because' + CRLF;
     533  TX_NO_DLL    = 'no copy of BORLNDMM.DLL can be found' + CRLF +
     534                 'in your workstation''s current PATH.';
     535  TX_OLD_DLL1  = 'the copy of BORLNDMM.DLL located at:' + CRLF + CRLF;
     536  TX_OLD_DLL2  = CRLF + CRLF + 'is out of date  (Version ';
     537  TX_CALL_IRM  = CRLF + CRLF +'Please contact IRM for assistance.';
     538var
     539  DLLHandle: HMODULE;
     540  DLLNamePath: array[0..261] of Char;
     541  DLLVersion: string;
     542begin
     543  Result := TRUE;
     544  DLLHandle := GetModuleHandle('BORLNDMM.DLL');
     545  if DLLHandle <=0 then
     546  begin
     547    InfoBox(TX_NO_RUN + TX_NO_DLL + TX_CALL_IRM, TC_DLL_ERR, MB_ICONERROR or MB_OK);
     548    Result := FALSE;
     549    Exit;
     550  end;
     551  Windows.GetModuleFileName(DLLHandle, DLLNamePath, 261);
     552  DLLVersion := ClientVersion(DLLNamePath);
     553  if StrToIntDef(Piece(DLLVersion, '.', 1), 0) < DLL_CURRENT_VERSION then
     554  begin
     555    InfoBox(TX_NO_RUN + TX_OLD_DLL1 + '   ' + DLLNamePath + TX_OLD_DLL2 + DLLVersion + ')' +
     556            TX_CALL_IRM, TC_DLL_ERR, MB_ICONERROR or MB_OK);
     557    Result := false;
     558  end;
     559end;
     560
    553561end.
Note: See TracChangeset for help on using the changeset viewer.