I can tell you one thing; you're not going to be able to return "my_string" as the class type "string." DB just won't take it. Furthermore, unless you actually plan on ever building this as anything but a DLL, I suggest you take out the "#if BUILDING_DLL" line.
Either way, you definitely need the DB pointer in there. For that you need to set up the DirectX SDK, dig out the globstruct.h header buried in ".\[Name of your DBPro folder]\Help\documents\Files\Third Party Commands\TESTCOMMANDS2\".
Finally, once you tweaked everything so your compiler will actually find the files pointed to by globstruct, toss this code into your header section:
#include "globstruct.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
//Global constructs go here
GlobStruct* g_pGlob = NULL;
__declspec(dllexport)
void Constructor ( void )
{
// Create memory here
}
__declspec(dllexport)
void Destructor ( void )
{
// Free memory here
}
__declspec(dllexport)
void ReceiveCoreDataPtr ( LPVOID pCore )
{
// Get Core Data Pointer here
g_pGlob = (GlobStruct*)pCore;
}
If there is an easier way to set this up, I'd love to hear it. As for your string return code, it should look something like this:
__declspec(dllexport)
DWORD GetHelloWorld(DWORD pOldString,DWORD pNewString)
{
// This is where the return string will go.
LPSTR pReturnString;
// This is the size of the string we're stuffing in.
DWORD dwSize;
// In the unlikely event of the specified
// string containing information already,
// dump it out - otherwise this creates a
// memory leak of sorts.
if(pOldString)
g_pGlob->CreateDeleteString( (DWORD*)&pOldString, 0 );
// Get the size of the new string
// so we know how much space to
// allocate.
dwSize=strlen( pNewString );
// All purpose memory allocation "CreateDelete"
g_pGlob->CreateDeleteString( (DWORD*)&pReturnString, dwSize+1 );
strcpy(pReturnString, pNewString);
}
// Return new string pointer
return (DWORD)pReturnString;
}
I'll be mildly amazed if someone can get this to work just by reading a forum tutorial. DBPro does not like receiving strings at all.
<i><sub>If we end up having to choose a national language, I'm voting for LISP.</sub></i>