我的方法,以获得MYSQL4.1版本为例:
uses
.......,registry;
........
procedure TMainForm.N31Click(Sender: TObject);
var
mysqldir:string;
aregistry:tregistry;
begin
//获取MYSQL的安装路径
aregistry:=tregistry.Create;
with aregistry do
begin
rootkey:=HKEY_LOCAL_MACHINE;
if openkey('SOFTWARE/MySQL AB/MySQL Server 4.1',false) then
begin
mysqldir:=readstring('Location');
end;
closekey;
destroy;
end;
end;