1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
unit fpcygwin;
interface
function GetCygwinVersionString : string;
function GetCygwinFullName : string;
function GetCygwinVersionHigh : longint;
function GetCygwinVersionLow : longint;
procedure CheckCygwinVersion;
implementation
uses
strings,
windows;
var
ModuleH,DummyH : Handle;
CygwinFullName : pchar;
fileinfosize : cardinal;
size : longint;
InfoData : pointer;
FileInfo : VS_FIXEDFILEINFO;
PFileInfo : ^VS_FIXEDFILEINFO;
function GetCygwinVersionHigh : longint;
begin
GetCygwinVersionHigh:=FileInfo.dwFileVersionMS;
end;
function GetCygwinVersionLow : longint;
begin
GetCygwinVersionLow:=FileInfo.dwFileVersionLS;
end;
function GetCygwinVersionString : string;
var
a,b,c,d : word;
va,vb,vc,vd : string[6];
begin
a:= Cardinal(GetCygwinVersionHigh) shr 16;
b:= Cardinal(GetCygwinVersionHigh) and $ffff;
c:= Cardinal(GetCygwinVersionLow) shr 16;
d:= Cardinal(GetCygwinVersionLow) and $ffff;
system.str(a,va);
system.str(b,vb);
system.str(c,vc);
system.str(d,vd);
GetCygwinVersionString:=va+'.'+vb+'.'+vc+'.'+vd;
end;
procedure CheckCygwinVersion;
begin
if GetCygwinVersionHigh < 1005 shl 16 then
begin
Writeln('The cygwin1.dll that you have in "',CygwinFullName,'" is too old');
Writeln('If the IDE does not work correctly, please consider');
Writeln('putting a newer cygwin1.dll version in your path before that one.');
end;
end;
function GetCygwinFullName : string;
begin
if assigned(CygwinFullName) then
GetCygwinFullName:=strpas(CygwinFullName)
else
GetCygwinFullName:='cygwin1.dll';
end;
initialization
ModuleH:=GetModuleHandle('cygwin1');
GetMem(CygwinFullName,MAX_PATH+1);
GetModuleFileName(ModuleH,CygwinFullName,MAX_PATH+1);
size:=GetFileVersionInfoSize(CygwinFullName,@DummyH);
GetMem(InfoData,size);
if GetFileVersionInfo(CygwinFullName,DummyH,size,InfoData) then
begin
PFileInfo:=nil;
VerQueryValue(InfoData,'\',PFileInfo,fileinfosize);
If Assigned(PFileInfo) then
FileInfo:=PFileInfo^;
end;
FreeMem(InfoData,size);
finalization
FreeMem(CygwinFullName,MAX_PATH+1);
end.
|