DirectX multiple DLL versions?
I see that DirectX 9 has multiple DLL versions, like
- d3d9.dll
- d3d9_25.dll
- d3d9_42.dll
- d3d9_43.dll
I'm wondering what the differences are, and how I can detect it? I have always been using GetModuleHandle("d3d9.dll");
, but if an application has d3d9_43.dll
, then my code will not detect that the application is using DirectX, will I? How would I go about detecting it without hardcoding all the DLL versions?
If code uses D3D9, it will always use d3d9.dll
at some point. Typically this is in the import table, but it can be dynamically linked (LoadLibrary
). d3d9.dll
provides the init code for D3D (and COM, when needed), and exports Direct3DCreate9
to create a new IDirect3D9Object
.
d3d9.dll
is used regardless of version, the version is specified by passing D3D_SDK_VERSION
to Direct3DCreate9
as the only parameter. This indicates what version should be used, not any DLL names.
The numbered files most often seen are D3D X files. These are versioned, with _43 referring to the June 2010 SDK (each SDK release has one, I believe). If a program needs the helper functions provided in D3DX, the latest version from the SDK is typically linked against, with the numbers keeping them separate.
The D3D9_[number] files which are not part of D3DX follow the same system (and likely have the same SDK version to number relation) and similarly provide version-specific features.
This is not say d3d9.dll
is not used; a vast supermajority of software uses that file (in fact, I've not personally seen a D3D9 app which didn't). Linking against D3D9.dll and passing the SDK version is the proper and recommended method for using D3D9. Testing for it is safe and reliable, and the simplest way to check the version is to intercept the call to Direct3DCreate9
.
精彩评论