Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (1)


Determening DirectX version installed on the systemFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 3.x (or higher)
Category:
Graphic
Skill Level:
Scoring:
Last Update:
01/27/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet directx version installed determine
Times Scored:
3
Visits:
3914
Uploader: Uros Gaber
Company:
Reference: N/A
 
Question/Problem/Abstract:
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;





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Alternate way...
    anonymus (Jan 28 2002 6:02PM)

Together with "Version" key there is an "InstalledVersion" key that contains the informations you need!

This is how to do it:

function GetDirectXVersion(var major, minor: word): boolean;
var Reg: TRegistry;
    str: string;
    res: boolean;
    DXVersion: record
                 Major: Longword;
                 Minor: Longword;
               end;

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;
      Reg.ReadBinaryData('InstalledVersion', DXVersion, SizeOf(DXVersion));
    end;
  finally
    Reg.CloseKey;
    Reg.Free;
  end;

  if res then
  begin
    Major:=HiByte(hiWord(DXVersion.Major));
    Minor:=HiByte(hiword(DXVersion.Minor));
  end;

  Result := res;
end;

Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
E. Irigoyen
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)