Archived

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

Bypassing 'Missing D3D8.dll' message?

This topic is 6027 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

How do you bypass the ''Missing D3D8.DLL'' message when running a Dx8 game without DX8 installed? I would like my game to display a message like "DirectX8 not installed, please download it from www.microsoft.com/directx" when receiving a failure error from Direct3DCreate8(). Demo Download: www.angelfire.com/realm/zeroone

Share this post


Link to post
Share on other sites
There''s two ways (that I can think of). One is to not statically link to the .dll. That is, load it with LoadLibrary() and then use GetProcAddress() to get pointers to all the functions you use. This shouldn''t be much of a problem, since you only need a couple (since after calling CreateDirect3D8() or whatever, all other methods are members of the IDirect3D8 interface)

The other way is to have two execultables, one which just checkes for DirectX, and the other which is the actual game. The one that checks for DirectX doesn''t need to link to the DirectX .dll since it only needs to do a LoadLibrary( "d3d8.dll" ); to see if you have DirectX 8. Once it checks, it can just call your normal executable.

The second method is best done in an install program though - have the installer detect for DirectX. If it''s not there, you can have it direct the user to the microsoft web page.


War Worlds - A 3D Real-Time Strategy game in development.

Share this post


Link to post
Share on other sites
I''d go with the first choice and not statically linked. This way you don''t have to worry about a missing game .exe and provide messages for that.

Here''s some quick code for that:

  
typedef IDirect3D8* (WINAPI* DIRECT3DCREATE8)(UINT);

void DirectX8Message()
{
MessageBox(0, "DirectX 8 not installed. Please download it from http://www.microsoft.com/directx", "Error", MB_ICONEXCLAMATION);

}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HINSTANCE hD3d = LoadLibrary("d3d8.dll");
if (!hD3d)
{
DirectX8Message();
return -1;
}

DIRECT3DCREATE8 _Direct3DCreate8 = (DIRECT3DCREATE8)GetProcAddress(hD3d, "Direct3DCreate8");
if (!_Direct3DCreate8)
{
DirectX8Message();
return -1;
}

// now you can use _Direct3DCreate8 as if it was the actual

// dx function


// rememember to FreeLibrary(hD3d) at the end of the program


// continue with the game...

}

Share this post


Link to post
Share on other sites