DirectX 7 and CBuilder

I have been using DX6.1, where I develloped an application in, but now I switched to DX7 because of some new functions. I copied the libraries in the lib/borland directory of the SDK and and the include files to my CBuilder directory. I changed a bit in the code so the my app is now using the IDD_IDirectDraw7 interface of the object, but the linker returns the following error: "Unresolved external 'DirectDrawCreateX' referenced from C:\DATA\PORT.OBJ."
What should I do to make the program run again?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

nils pipenbrinckConnect With a Mentor Commented:
Hi upanishadiii  (cool name!)

I guess you mean the function DirectDrawCreateEx function...

Well.. I don't wonder that the linker doesn't find the function. The function DirectDrawCreateEx is not in the library file.

If you want to call it (you will) you have to use LoadLibrary to load the ddraw.dll and GetProcAddress to get the pointer to the function (take a look into the api help for those two).

The reason why Microsoft decided not to put this function into the lib is to force us to be compatible with the DirectX 6.1 dll.

If GetProcAddress fails you can display a messagebox that directx is outdated.

This is a lot better than a system-message which complains a non-existent entry-point in a dll (at least for the users side of view).

upanishadiiiAuthor Commented:
Adjusted points to 60
upanishadiiiAuthor Commented:
Thanx for this. I'll test it.
F***ing Microsoft.
I've never loaded a DLL before to use DirectX.
I have seen them using it in there examples, without loading the DLL. I know how to do this, but I have to test it.

upanishadiiiAuthor Commented:
It worked very well. Less trouble than expected. Thanx for the answer. I'll give you the points. DO you happen to know how it's possible that the RestoreAllSurfaces function doesn't work in Exclusive mode. When I press ALT+TAB it directly gives the error: Surfaces have been lost...
Nothing draws to the surfaces when I deactivate, or hide the application.
I'll give you points for that as well, but I ask it now because Maybe it can take some time before anyone else knows the answer.
nils pipenbrinckCommented:
my idea about that alt-tab thing is, that you can only restore the surfaces if your program has the focus.

At least that's what I do when I do directsound streaming. I lock the primary sound buffer. It fails if the user task-switches to another program.

If he however switches back to the game the Restore function succeeds.

Maybe it's the same with the ddraw surfaces here..

btw. if you have graphics/textures loaded they will be trashed after a task-switch. you have to load them again. (at least on my card).

All Courses

From novice to tech pro — start learning today.