Try this - comments have been added. Just search for IRM to see my notes.
#include <windows.h>
#include "globstruct.h"
//?ReceiveCoreDataPtr@@YAXPAX@Z
GlobStruct *g_pGlob; //the globstruct
void ReceiveCoreDataPtr( void *cdp ){ //need this
g_pGlob = (GlobStruct *) cdp;
}
typedef void(__cdecl *tText)(int, int, char*);
// IRM - Don't do this here - g_pGlob is NOT populated until ReceiveCoreDataPtr
// has been call, which happens after the following line is called.
//tText Text = (tText)GetProcAddress(g_pGlob->g_Text,"?BasicText@@YAXHHK@Z");
/*******************************
Extern "C" comes in handy because in the core_data.def file you just type out the function name
instead of going into notepad to try to find the mangled name
in res.rc which is the string table, the last name(the function name to be called); with extern "C" you
just type the function name, no mangled name crap
oh and btw don't use the "strip all symbols from binary" optimization
also the libsample.def is automatically made, if you edit it then it won't affect anything
******************************/
extern "C"{
DWORD TestText(int x,int y,char* str)
{
// IRM - Moved line here, and made it static so that it is only called once
// the first time the function is called.
static tText Text = (tText)GetProcAddress(g_pGlob->g_Text,"?BasicText@@YAXHHK@Z");
Text(x,y,str);
}
}
NOTE: This code has not been tested, but should work just fine.
You might need to add a leading underscore to your function name in the string resource file if DBPro can't find the function ... I can't remember how Dev-C++ deals with extern C functions.