在[code]段下,写这两个函数后,能根据不同的系统安装不同的程序,但是不能判断该程序是否已安装。代码如下:
var
nt5: Boolean;
nt6: Boolean;
Version: TWindowsVersion;
function IsNT5(): Boolean;
begin
Result := nt5;
end;
function IsNT6(): Boolean;
begin
Result := nt6;
end;
function InitializeSetup(): Boolean;
begin
GetWindowsVersionEx(Version);
nt5 := False;
nt6 := False;
if Version.NTPlatform then begin
if (Version.Major = 5) then begin
nt5 := True;
end;
if(Version.Major = 6) then begin
nt6 := True;
end;
end;
Result := True;
end;
//安装前判断是否已安装
function InitializeSetup2(): Boolean;
var
sName: String;
begin
Result := True;
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\XytClient', 'MyAppVerName', sName) then
if sName = '信易通系统智能维护平台 V0.1' then
begin
Result:= False;
MsgBox('你系统中已经安装了该程序,没必要在安装了。', mbInformation, MB_OK);
end;
end;
end;