Subversion Repositories userdetect2

Rev

Rev 92 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 92 Rev 95
Line 40... Line 40...
40
function FormatOSError(ec: DWORD): string;
40
function FormatOSError(ec: DWORD): string;
41
function CheckBoolParam(idx: integer; name: string): boolean;
41
function CheckBoolParam(idx: integer; name: string): boolean;
42
function IndexOf_CS(aStrings: TStrings; aToken: string): Integer;
42
function IndexOf_CS(aStrings: TStrings; aToken: string): Integer;
43
function UD2_GetThreadErrorMode: DWORD;
43
function UD2_GetThreadErrorMode: DWORD;
44
function UD2_SetThreadErrorMode(dwNewMode: DWORD; lpOldMode: LPDWORD): BOOL;
44
function UD2_SetThreadErrorMode(dwNewMode: DWORD; lpOldMode: LPDWORD): BOOL;
-
 
45
function GetFileVersion(const FileName: string=''): string;
45
 
46
 
46
implementation
47
implementation
47
 
48
 
48
uses
49
uses
49
  idhttp, Forms;
50
  idhttp, Forms;
Line 422... Line 423...
422
    if result <> '' then result := result + glue;
423
    if result <> '' then result := result + glue;
423
    result := result + ary[i];
424
    result := result + ary[i];
424
  end;
425
  end;
425
end;
426
end;
426
 
427
 
-
 
428
function GetFileVersion(const FileName: string=''): string;
-
 
429
var
-
 
430
  lpVerInfo: pointer;
-
 
431
  rVerValue: PVSFixedFileInfo;
-
 
432
  dwInfoSize: cardinal;
-
 
433
  dwValueSize: cardinal;
-
 
434
  dwDummy: cardinal;
-
 
435
  lpstrPath: pchar;
-
 
436
  a, b, c, d: word;
-
 
437
resourcestring
-
 
438
  LNG_NO_VERSION = 'No version specification';
-
 
439
begin
-
 
440
  if Trim(FileName) = EmptyStr then
-
 
441
    lpstrPath := pchar(ParamStr(0))
-
 
442
  else
-
 
443
    lpstrPath := pchar(FileName);
-
 
444
 
-
 
445
  dwInfoSize := GetFileVersionInfoSize(lpstrPath, dwDummy);
-
 
446
 
-
 
447
  if dwInfoSize = 0 then
-
 
448
  begin
-
 
449
    Result := LNG_NO_VERSION;
-
 
450
    Exit;
-
 
451
  end;
-
 
452
 
-
 
453
  GetMem(lpVerInfo, dwInfoSize);
-
 
454
  try
-
 
455
    GetFileVersionInfo(lpstrPath, 0, dwInfoSize, lpVerInfo);
-
 
456
    VerQueryValue(lpVerInfo, '', pointer(rVerValue), dwValueSize);
-
 
457
 
-
 
458
    with rVerValue^ do
-
 
459
    begin
-
 
460
      a := dwFileVersionMS shr 16;
-
 
461
      b := dwFileVersionMS and $FFFF;
-
 
462
      c := dwFileVersionLS shr 16;
-
 
463
      d := dwFileVersionLS and $FFFF;
-
 
464
 
-
 
465
      Result := IntToStr(a);
-
 
466
      if (b <> 0) or (c <> 0) or (d <> 0) then Result := Result + '.' + IntToStr(b);
-
 
467
      if (c <> 0) or (d <> 0) then Result := Result + '.' + IntToStr(c);
-
 
468
      if (d <> 0) then Result := Result + '.' + IntToStr(d);
-
 
469
    end;
-
 
470
  finally
-
 
471
    FreeMem(lpVerInfo, dwInfoSize);
-
 
472
  end;
-
 
473
 
-
 
474
end;
-
 
475
 
427
end.
476
end.