i need to check the sql server version every time my application installation begins through inno setup. but as sql creates the server version specific entry(like MySQL Server 5.1) as key in the registry, so i have to give the path like
HKLM\SOFTWARE\Wow6432Node\MySQL AB\MySQL Server 5.1
while checking the version.
but when i install the sql server having version other than 5.1, it checks on the above path, it couldn't find. so again installation begins although it is already installed. so i want some generic path like
HKLM\SOFTWARE\Wow6432Node\MySQL AB\MySQL Server
which is not version specific. so that i can easily retreive the value from the MySQL key and check for it.My Code is
function fCheckMySQLInstall():boolean;
var
mysqlVersion : string;
begin
bIsMyQLInstalled := False;
if RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\MySQL AB\MySQL Server 5.1', 'Version', mysqlVersion) = true then
if CompareStr(mysqlVersion,'5.1') >= 0 then
bIsMyQLInstalled := True;
Result := bIsMyQLInstalled;
end;
as the path is /MySQL Server 5.1 which is not correct. should be generic for all version so that i can check for other version. Solutions are welcome.
what i have done is. get all the versions of mySQL server from the registry(for how see the code below!). after extracting all the versions, compare the version of mysql to be installed to extracted version and decide whether to install or not. detailed explanantion is given in mycode.
if RegGetSubkeyNames(HKLM, URL, mysqlVersion) then
begin
counter := 0;
specificVersion := '';
for mysqlVersionIteration := 0 to GetArrayLength(mysqlVersion)-1 do begin
specificVersion := mysqlVersion[mysqlVersionIteration];
res := copy(specificVersion,1,12);
if(res = 'MySQL Server')then
if RegQueryStringValue(HKLM, URL+'\'+specificVersion, 'Version', Version) = true then
begin
SetArrayLength(extractedVersion, counter + 1);
extractedVersion[counter] := Version;
counter := counter + 1;
end;
end;
for CompareVersionCount:= 0 to GetArrayLength(extractedVersion) - 1 do begin
alreadyVersionExists:= copy(extractedVersion[CompareVersionCount],1,3);
if CompareStr(alreadyVersionExists,'{#MySQLVersion}') >= 0 then
bIsMyQLInstalled := True;
end;
end;
- here URL is "SOFTWARE\Wow6432Node\MySQL AB" in case of win64 and 'SOFTWARE\MySQL AB' in case of win32
- iterate through all the subkeys.
- extract first 12 letters, because there might be other subkeys.
- if that extracted letter is MySQL then the key must have mySQL version.
- extract the version of that particular key.
- put all the version already present in the system in extractedVersion array.
- at last iterate through the extractedVersion array and compare it to version of mySQL to be installed and decide whether to install or not.
By this method my installer does what i supposed to do.