[AD] patch for detecting DX8,9 |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
attached is a patch for detecting directX versions 8 and 9.
made for 4.1.18
aj.
--- ..\allegro_4_1_18__original\src\win\wdxver.c 2004-03-22 14:25:00.000000000 +1100
+++ src\win\wdxver.c 2005-02-22 16:41:22.375000000 +1100
@@ -44,8 +44,7 @@
typedef HRESULT(WINAPI *DIRECTDRAWCREATE) (GUID *, LPDIRECTDRAW *, IUnknown *);
typedef HRESULT(WINAPI *DIRECTINPUTCREATE) (HINSTANCE, DWORD, LPDIRECTINPUT *, IUnknown *);
-
-
+typedef HRESULT(WINAPI *DSETUPCREATE)(DWORD*,DWORD*);
/* get_dx_ver:
* returns the DirectX dx_version number:
@@ -63,14 +62,19 @@
HRESULT hr;
HINSTANCE ddraw_hinst = NULL;
HINSTANCE dinput_hinst = NULL;
+ HINSTANCE dsetup_hinst = NULL;
LPDIRECTDRAW directdraw = NULL;
LPDIRECTDRAW2 directdraw2 = NULL;
DIRECTDRAWCREATE DirectDrawCreate = NULL;
DIRECTINPUTCREATE DirectInputCreate = NULL;
+ DSETUPCREATE DSetupCreate = NULL;
OSVERSIONINFO os_version;
LPDIRECTDRAWSURFACE ddraw_surf = NULL;
LPDIRECTDRAWSURFACE3 ddraw_surf3 = NULL;
+ DWORD dsetup_revision;
+ DWORD dsetup_version;
+ INT dsetup_result;
+
#if DIRECTX_SDK_VERSION >= 0x600
LPDIRECTDRAWSURFACE4 ddraw_surf4 = NULL;
@@ -98,7 +102,42 @@
return dx_version;
}
- if (os_version.dwMajorVersion == 4) {
+
+ dsetup_hinst = LoadLibrary( "DSETUP.DLL" );
+ if ( dsetup_hinst ) {
+ DSetupCreate = (DSETUPCREATE)GetProcAddress(dsetup_hinst, "DirectXSetupGetVersion");
+ if ( DSetupCreate ) {
+ dsetup_result = DSetupCreate( &dsetup_version, &dsetup_revision ); // returns 0 on failure
+ if ( dsetup_result ) {
+ if ( 0x00040005 == dsetup_version ) dx_version = 0x500;
+ if ( 0x00040006 == dsetup_version ) dx_version = 0x600;
+ if ( 0x00040007 == dsetup_version ) dx_version = 0x700;
+
+ if ( 0x00040008 == dsetup_version ) { /* v8.x */
+ dx_version = 0x800;
+ if ( 0x0001032A == dsetup_revision ) dx_version = 0x801; /* 8.1 */
+ if ( 0x00010371 == dsetup_revision ) dx_version = 0x801; /* 8.1 */
+ if ( 0x00010385 == dsetup_revision ) dx_version = 0x81a; /* 8.1a */
+ if ( 0x00010385 == dsetup_revision ) dx_version = 0x81b; /* 8.1b */
+ if ( 0x00020386 == dsetup_revision ) dx_version = 0x820; /* 8.2 */
+ }
+ if ( 0x00040009 == dsetup_version ) {
+ dx_version = 0x900;
+ if ( 0x00000384 == dsetup_revision ) dx_version = 0x900; /* 9.0 */
+ if ( 0x00000385 == dsetup_revision ) dx_version = 0x90a; /* 9.0a */
+ if ( 0x00000386 == dsetup_revision ) dx_version = 0x90b; /* 9.0b */
+ if ( 0x00000387 == dsetup_revision ) dx_version = 0x90b; /* 9.0(b|c) */
+ if ( 0x00000388 == dsetup_revision ) dx_version = 0x90c; /* 9.0c */
+ }
+ }
+ }
+ FreeLibrary( dsetup_hinst );
+ if ( dx_version )
+ return dx_version;
+ }
+
+
+ if (os_version.dwMajorVersion == 4) {
/* NT4 up to SP2 is DX2, and SP3 onwards is DX3, so we are at least DX2 */
dx_version = 0x200;