Check which version of DirectX is installed

后端 未结 2 1994
悲&欢浪女
悲&欢浪女 2021-01-06 05:07

As per the title, how can I check which version of DirectX a user has installed? Checking the FeatureLevel isn\'t enough, as my application can run on feature level 10.0, bu

2条回答
  •  清歌不尽
    2021-01-06 05:57

    EDIT: Removed registry check method because it works only for Dx <=9 (thx @Telanor)

    This method is very, very slow, but only one I figured out that is 100% accurate

    private static int checkdxversion_dxdiag()
    {
        Process.Start("dxdiag", "/x dxv.xml");
        while (!File.Exists("dxv.xml"))
            Thread.Sleep(1000);
        XmlDocument doc = new XmlDocument();
        doc.Load("dxv.xml");
        XmlNode dxd = doc.SelectSingleNode("//DxDiag");
        XmlNode dxv = dxd.SelectSingleNode("//DirectXVersion");
    
        return Convert.ToInt32(dxv.InnerText.Split(' ')[1]);
    }
    

提交回复
热议问题