Quote: "Apparently the DLL compiles fine"
It does? Maybe for you, but not for me - you don't have a DllMain. Also, you shouldn't load the DLL with a full pathname in this case, because it's not the one you are executing.
Changed code:
//include windowz
#include <windows.h>
//include my header
#include "myCommands.h"
//make my function to wrap DBP's function
DLLCOMMAND void PositionObject( int oID, float x,float y,float z )
{
//get handle on the dbp dll
HMODULE hDBPCommands = LoadLibrary("DBProBasic3DDebug.dll"); // IRM - Don't need full pathname, it's part of the exe (not the full story but ...)
if(!hDBPCommands)
{
MessageBox(NULL, "Fatal Error: LoadLibrary failed to load the library","FATAL ERROR IN USER PLUGIN", NULL);
}
//get hands on the function i want to use
LFFF_function_pointer posObject = (LFFF_function_pointer)GetProcAddress( hDBPCommands, "?Position@@YAXHMMM@Z" );
if(!posObject)
{
MessageBox(NULL, "Fatal Error: GetProcAddress failed to return function address","FATAL ERROR IN USER PLUGIN", NULL);
FreeLibrary( hDBPCommands );
}
//call function
posObject( oID, x,y,z );
//free library from memory
FreeLibrary( hDBPCommands );
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
DBPro test code:
sync on
sync rate 60
autocam off
make object cube 1, 1.0
do
for i = -50 to 50
WRAPPED COMMAND POS OBJ 1, i/50.0, 0.0, 10.0
sync
next
for i = 50 to -50 step -1
WRAPPED COMMAND POS OBJ 1, i/50.0, 0.0, 10.0
sync
next
loop
When you compile your DBPro program, a copy of your DLL is included in the exe file, along with a copy of the Basic3D file.
When you execute the exe, everything is unpacked into a temporary directory and run from there.
What was happening was you were using LoadLibrary on a completely different Basic3D DLL and calling its function, not the one in the local copy being run by your program.