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!
To check DirectX10, we're actually calling the D3DX10CheckVersion function via platform invoke.
This requires presence of the D3DX10 DLLs in the C:\Windows\System32 or C:\Windows\SysWow64 folders (platform dependent). If these are not present, then you need to install the DirectX10 Runtime on the target PC.
The actual support DirectX version / DirectX SDK version can be determined from the parameters to the P/Invoke call.
Here is the P/Invoke call:
You can have a look at the DirectX version installed on your machine using this key hive
Here's a sample
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 :)
It's actually very simple: If you are on Windows Vista / Server 2008 or later, you have "DirectX 10" the API. If you are on Windows Vista / Server 2008 Service Pack 1 or later, you have "DirectX 10.1" the API.
Neither of these answer the more useful question of: does the system have a DirectX 10 compatible video device and driver?
Really the only sure way to detect this is to create the device. If you can (a) find the
D3D10.DLL
and (b) a call toD3D10CreateDevice
succeeds, then you have both the DirectX 10 API and a 10 compatible device.Similarly, if you can (a) find the
D3D10_1.DLL
and (b) a call toD3D10CreateDevice1
succeeds, then you have both the DirectX 10.1 API and a 10.0 or 10.1 compatible device.DirectX 11.0 or later is always present on Windows 7 / Server 2008 R2 or later. Again, if you can (a) find the
D3D11.DLL
and (b) a call toD3D11CreateDevice
succeeds, then you have both the DirectX 11 API and a 11 compatible device of some feature level. The parameters to the create device will determine what feature levels are allowed. This procedure will also work to detect the case that you are on a Windows Vista / Server 2008 Service Pack 2 system with the KB97644 update applied.Once you have a
ID3D11Device
you can QueryInterface forID3D11Device1
to see if the system has DirectX 11.1 (Windows 8 / Server 2012 or Windows 7 / Server 2008 R2 with KB2670838, orID3D1Device2
to see if the system has DirectX 11.2 (Windows 8.1 / Server 2012 R2)See Direct3D 11 Deployment for Game Developers
The concept of "What version of DirectX is installed" is antiquated and dates back to the era of Windows 9x/ME. Running the "DirectX End-User Runtime Redist" does some stuff, but it never installs a new version of DirectX. See Not So DirectSetup. The DirectX runtime is purely a function of OS patch level and has been since ~2004. See What's in a version number? as well.