Archived

This topic is now archived and is closed to further replies.

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

This topic is 5113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
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 ]]

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites