is there an easy way to detect directX prior loading DX dlls?

Started by
5 comments, last by vicviper 20 years, 4 months ago
I have this problem: recently, one of our little projects went on sale, and we had the very bad idea to use DirectX9 in that project. A lot of people has called to us asking "the program does not run, what is directX ?" so I decided to add some directX detection code, and if it fails, execute the DirectX installation setup. problem is, since DirectX DLLs are loaded in the program space when the exe header is executed, there''s no way to do a proper detection, because, when the program is executed in a system without DirectX 9, it inmediately says the annoying "d3d9.dll not found" and the program exits, even before executing the detection code. so, how to solve this? this is very important to us, because we have noticed how dumb is people out there... some weeks ago we got a call from a customer telling that he was not able to play the game... after half an hour, we discovered that he didn''t even opened the box containing the CD... it seems he beleaved the program would execute just by placing the box close to the computer, or something like that... (no, it''s not a joke)
Advertisement
Take a look at DirectXSetup.
Yeah, just add DirectXSetup as a part of your installation process. I take it your game was distributed on traditional media? (And if so, congrats!) Slapping on DXSetup and then calling it as a post-installation operation like a lot of commerical games do is viable. For online distribution, that isn''t quite the case however.

You could encapsulate your program in a "wrapper" app. A single EXE that does not contain any DX code at all, but simply launches a startup screen where the player can configure game settings, visit your website, etc. It can then check for DX and if not found, alert the player. (I''m sure there is some Win32 API calls for detecting whether or not certain DLLs are installed -- perhaps the versioning calls?) If all is OK, it just exec()''s your main game''s binary that will be renamed to something non-obvious.

I used to use that wrapper trick to make a bunch of seperate QuickBASIC EXE''s link together and seem like one integrated game. (Since QB''s compiler had a tendicy to barf and die if your program used more than around 48k of global code space, therefore it was necessary to break up the game into smaller segments.) But I guess I''m just showing my age, so I''ll shutup now.



---
[[ Gaping Wolf Software ]]
--- - 2D/Pixel Artist - 3D Artist - Game Programmer - Ulfr Fenris[[ Gaping Wolf Software ]] [[ GameGenesis Forums ]]
If you don''t link to d3d9.lib you can call LoadLibrary yourself. Can''t post a snippet (no docs or source available ATM) but should give you a nudge in the right direction.

Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
HMODULE LibD3D = LoadLibrary("D3D9.DLL");if (LibD3D == NULL)	throw "ERROR: Could not load Direct3D library (D3D9.DLL) - DirectX 9 required!";typedef LPDIRECT3D9 (WINAPI* type_Direct3DCreate9)(UINT);type_Direct3DCreate9 dyn_Direct3DCreate9;dyn_Direct3DCreate9 = (type_Direct3DCreate9)GetProcAddress(LibD3D,"Direct3DCreate9");if (NULL == (D3D = dyn_Direct3DCreate9(D3D_SDK_VERSION)))	throw "ERROR: Could not create Direct3D object - DirectX 9 required!";

I know there's some extra code there that isn't strictly required... some is there for clarity, and some is there simply because this is more or less a cut-and-paste from my 3D library.

[edited by - Mattias Welander on December 16, 2003 5:47:16 PM]
Won''t that generate linker errors, though, if you compile without the .lib? I''m not in-the-known with Win API, so not sure how this works.

---
[[ Gaping Wolf Software ]]
--- - 2D/Pixel Artist - 3D Artist - Game Programmer - Ulfr Fenris[[ Gaping Wolf Software ]] [[ GameGenesis Forums ]]
Not if it is done correctly. You only need the lib if your application is made to dynamically link to a dll.
.

This topic is closed to new replies.

Advertisement