Changeset 829 for cprs/trunk/CPRS-Lib/ORSystem.pas
- Timestamp:
- Jul 7, 2010, 4:31:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Lib/ORSystem.pas
r456 r829 2 2 3 3 {$O-} 4 {$WARN SYMBOL_PLATFORM OFF} 4 5 5 6 interface … … 19 20 CPRS_LAST_DATE = 'Software\Vista\CPRS\DateUpdated'; 20 21 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 33 22 function AppOutOfDate(AppName: string): Boolean; 34 23 function ClientVersion(const AFileName: string): string; … … 40 29 //procedure FileCopy(const FromFileName, ToFileName: string); 41 30 //procedure FileCopyWithDate(const FromFileName, ToFileName: string); 42 function FileVersionValue(const AFileName, AValueName: string): string;43 31 function FullToFilePart(const AFileName: string): string; 44 32 function FullToPathPart(const AFileName: string): string; … … 60 48 procedure RunProgram(const AppName: string); 61 49 function UpdateSelf: Boolean; 50 function BorlandDLLVersionOK: boolean; 62 51 63 52 implementation … … 110 99 // check for different file date in the gold directory 111 100 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; 113 112 GoldName := GoldName + FullToFilePart(AppName); 114 113 if FileExists(GoldName) then … … 139 138 IntToStr(HIWORD(dwFileVersionLS)) + '.' + 140 139 IntToStr(LOWORD(dwFileVersionLS)); 141 end;142 end;143 144 function FileVersionValue(const AFileName, AValueName: string): string;145 type146 PValBuf = ^TValBuf;147 TValBuf = array[0..255] of Char;148 var149 VerSize, ValSize, AHandle: DWORD;150 VerBuf: Pointer;151 ValBuf: PValBuf;152 begin153 Result := '';154 VerSize:=GetFileVersionInfoSize(PChar(AFileName), AHandle);155 if VerSize > 0 then156 begin157 GetMem(VerBuf, VerSize);158 try159 GetFileVersionInfo(PChar(AFileName), AHandle, VerSize, VerBuf);160 VerQueryValue(VerBuf, PChar(AValueName), Pointer(ValBuf), ValSize);161 SetString(Result, ValBuf^, ValSize);162 finally163 FreeMem(VerBuf);164 end;165 140 end; 166 141 end; … … 551 526 *) 552 527 528 function BorlandDLLVersionOK: boolean; 529 const 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.'; 538 var 539 DLLHandle: HMODULE; 540 DLLNamePath: array[0..261] of Char; 541 DLLVersion: string; 542 begin 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; 559 end; 560 553 561 end.
Note:
See TracChangeset
for help on using the changeset viewer.