我觉得在开始菜单里查最快。如果觉得不妥当,在到注册表里查。具体查找Microsoft SQL Server 7.0关键字,如果有说明安装过,否则,是干净的。
uses Registry;procedure TForm1.Button1Click(Sender: TObject); var vStringList: TStringList; I: Integer; begin vStringList := TStringList.Create; with TRegistry.Create do try RootKey := HKEY_LOCAL_MACHINE; if OpenKey('\Software\Microsoft\Windows\CurrentVersion\Uninstall\', False) then begin GetKeyNames(vStringList); for I := 0 to vStringList.Count - 1 do if Pos('Microsoft SQL Server', vStringList[I]) > 0 then ShowMessage(vStringList[I]); end; CloseKey; finally vStringList.Free; Free; end; end;
Registry;procedure TForm1.Button1Click(Sender: TObject);
var
vStringList: TStringList;
I: Integer;
begin
vStringList := TStringList.Create;
with TRegistry.Create do try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('\Software\Microsoft\Windows\CurrentVersion\Uninstall\', False) then begin
GetKeyNames(vStringList);
for I := 0 to vStringList.Count - 1 do
if Pos('Microsoft SQL Server', vStringList[I]) > 0 then
ShowMessage(vStringList[I]);
end;
CloseKey;
finally
vStringList.Free;
Free;
end;
end;