I would like to find out from .NET code whether DirectX 10 is supported on the machine, preferably without using managed DirectX or XNA assemblies.
Thank you in advance!
I would like to find out from .NET code whether DirectX 10 is supported on the machine, preferably without using managed DirectX or XNA assemblies.
Thank you in advance!
You can have a look at the DirectX version installed on your machine using this key hive
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectX
Here's a sample
[assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum,All = "HKEY_LOCAL_MACHINE")]
class Test
{
public int DxLevel
{
get
{
using(RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\DirectX"))
{
string versionStr = key.GetValue("Version") as string;
if (!string.IsNullOrEmpty(versionStr))
{
var versionComponents = versionStr.Split('.');
if (versionComponents.Length > 1)
{
int directXLevel;
if (int.TryParse(versionComponents[1], out directXLevel))
return directXLevel;
}
}
return -1;
}
}
}
}
Now if you want to know whether your video card supports DirectX, this is going to require XNA or DirectX interop.
Just a note, I couldn't test that code on my machine right now but that should get you started :)