Graphic Delphi

Title: Determening DirectX version installed on the system
Question: How do I determine the DirectX version if installed on the system?
Answer:
I was looking for a easy way to determine if MS-DirectX is installed on the system and what version it was...
As I was browsing through the system registry I found a key that holds the DirectX version number.
This function returns the major and minor version of DirectX, the minor version is not completely correct since the version number 4.06.02.0436 reflects DirectX 6.1, unfortunally I didn't find any resource stating what version number reflects DirectX version... I tested this on DirectX 6.1, 7.0 and 8.0.
If there is no DirectX installed on the system the function returns false and 0 as major and minor version number.
function GetDirectXVersion(var major, minor: word): boolean;
var Reg: TRegistry;
str: string;
res: boolean;
begin
str:='';
res:=false;
major:=0; minor:=0;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\Software\Microsoft\DirectX', False) then
begin
res:=true;
str:=Reg.ReadString('Version');
end;
finally
Reg.CloseKey;
Reg.Free;
end;
if res then
begin
Delete(str, 1, POS('.', str));
Major:=StrToInt(Copy(str, 1, POS('.', str)-1));
Delete(str, 1, POS('.', str));
Minor:=StrToInt(Copy(str, 1, POS('.', str)-1));
end;
GetDirectXVersion:=res;
end;