My C++ book didn't include any material regarding the use of dynamic and static link libaries. So I tried looking up the subject and all I could find where long snippets of confusing code which I didn't really understand. Anyway, I have had a go and it seems to be working (by the fact that I am not getting any compiler or run-time errors). Here is the code I have written:
The DLL I'm using is a 3D rendering libary by the way. So basicly my question is simply, am I doing this write? If not, what should I be doing? Thankyou for your time.
In you're example you are dynamically loading a DLL. In this case, each function you want to call from that DLL you need to first call GetProcAddress to get the address of each function. You need to know the function signatures to call them correctly. Search for this function on the internet for examples.
Okay thankyou, just having a little trouble understanding GetProcAddress, so would I have to something along the lines of this:FARPROC u3d_init = GetProcAddress(u3dDLL, "Render");
Yes, then you can check whether it failed or succeeded, if it failed it will return 0
1 2
if ( u3d_init != 0 )
// success!
As Bob said you will need to know the function signatures, to do this you can open a command prompt, navigate to the directory of your DLL, and enter "dumpbin /exports Ultimate3D.dll" which will list all of the symbols that are exported from the DLL. The function names are often mangled so if you start off with a function called 'func(int a)' it might be exported with a signature of '_func@4' or it could get completely messed up, something like ?func@@YAXH@Z' so you need to determine the signature using dumpbin.