Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DirectX9

DirectX9

Scheduled Pinned Locked Moved C#
questioncsharp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    electriac
    wrote on last edited by
    #1

    In C# code how can I detect if Directx9 is installed on the user machine?

    M 1 Reply Last reply
    0
    • E electriac

      In C# code how can I detect if Directx9 is installed on the user machine?

      M Offline
      M Offline
      markovl
      wrote on last edited by
      #2

      You can check the value of the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectX\Version registry key. This table[^] will show you the version according to the version number. For example 4.09.00.0904 is DirectX 9.0c.

      2A

      E 1 Reply Last reply
      0
      • M markovl

        You can check the value of the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectX\Version registry key. This table[^] will show you the version according to the version number. For example 4.09.00.0904 is DirectX 9.0c.

        2A

        E Offline
        E Offline
        electriac
        wrote on last edited by
        #3

        I was able to do this on XP but I can't get any code to work on Win X64 could you give me an example. TNX

        D 1 Reply Last reply
        0
        • E electriac

          I was able to do this on XP but I can't get any code to work on Win X64 could you give me an example. TNX

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You have to look at the same path under the SOFTWARE\Wow6432Node\...

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          E 1 Reply Last reply
          0
          • D Dave Kreskowiak

            You have to look at the same path under the SOFTWARE\Wow6432Node\...

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            E Offline
            E Offline
            electriac
            wrote on last edited by
            #5

            This seems to be working. Any suggestions? I guess I will have to identify the OS and have an alternative for XP - right? Many thanks!

            public void readRegistryForDX9()
            {
            RegistryKey rk = Registry.LocalMachine;
            RegistryKey sk = rk.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX");
            string temp = (string)sk.GetValue("Version");
            if (temp.IndexOf("4.09")<0) MessageBox.Show("Directx 9 Must be installed");
            else MessageBox.Show("Directx 9 already installed");
            return;
            }

            D M 2 Replies Last reply
            0
            • E electriac

              This seems to be working. Any suggestions? I guess I will have to identify the OS and have an alternative for XP - right? Many thanks!

              public void readRegistryForDX9()
              {
              RegistryKey rk = Registry.LocalMachine;
              RegistryKey sk = rk.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX");
              string temp = (string)sk.GetValue("Version");
              if (temp.IndexOf("4.09")<0) MessageBox.Show("Directx 9 Must be installed");
              else MessageBox.Show("Directx 9 already installed");
              return;
              }

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              You don't need to "read the OS". You just look under one registry path and if the value isn't there, you look under the other one. If it's not under either, DirectX isn't installed.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              1 Reply Last reply
              0
              • E electriac

                This seems to be working. Any suggestions? I guess I will have to identify the OS and have an alternative for XP - right? Many thanks!

                public void readRegistryForDX9()
                {
                RegistryKey rk = Registry.LocalMachine;
                RegistryKey sk = rk.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX");
                string temp = (string)sk.GetValue("Version");
                if (temp.IndexOf("4.09")<0) MessageBox.Show("Directx 9 Must be installed");
                else MessageBox.Show("Directx 9 already installed");
                return;
                }

                M Offline
                M Offline
                markovl
                wrote on last edited by
                #7

                What Dave said above should do it. One note though - be sure to free any resources used by the RegistryKey objects - encolsing them in using statements is good:

                using (RegistryKey sk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX"))
                {
                // the rest of your code;
                }

                It's also good practice to check sk for null as if the key's not present on the system sk.GetValue("Version") will thrown an exception. P.S. No need to explicitly return from a void method.

                2A

                E 1 Reply Last reply
                0
                • M markovl

                  What Dave said above should do it. One note though - be sure to free any resources used by the RegistryKey objects - encolsing them in using statements is good:

                  using (RegistryKey sk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX"))
                  {
                  // the rest of your code;
                  }

                  It's also good practice to check sk for null as if the key's not present on the system sk.GetValue("Version") will thrown an exception. P.S. No need to explicitly return from a void method.

                  2A

                  E Offline
                  E Offline
                  electriac
                  wrote on last edited by
                  #8

                  Markovl - TNX:

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups