No. That's the DBC way of returning strings and it's wrong for DBPro.
#include <windows.h>
#include <stdio.h>
#define EXPORT _declspec(dllexport)
#define EXPORTC extern "C" EXPORT
#include <globstruct.h>
// ---- SUPPORT FUNCTIONS ----
GlobStruct* GetCore()
{
static GlobStruct* CorePtr = NULL;
// If already have the core pointer, return it.
if (CorePtr)
return CorePtr;
// Get the core pointer ...
typedef GlobStruct* (__cdecl *tGetGlobPtr)(void);
HINSTANCE CoreHandle = LoadLibrary("DBProCore.dll");
tGetGlobPtr GetGlobPtr = (tGetGlobPtr)GetProcAddress( CoreHandle, "?GetGlobPtr@@YAKXZ" );
FreeLibrary( CoreHandle );
CorePtr = GetGlobPtr();
// ... and return it.
return CorePtr;
}
void DeleteString(LPCSTR OldStr)
{
if (OldStr)
{
GetCore()->CreateDeleteString( (DWORD *)&OldStr, 0);
}
}
LPSTR CreateString(int Size)
{
LPSTR NewString=NULL;
GetCore()->CreateDeleteString( (DWORD *)&NewString, Size);
return NewString;
}
LPSTR CreateString(LPCSTR Source)
{
return strcpy( CreateString( (int)strlen(Source)+1 ), Source );
}
// ---- User Code ----
EXPORTC char* TestFunc(LPSTR OldString, int Value)
{
// Remove the old string
DeleteString( OldString );
// Allocate a new string
LPSTR RetString = CreateString(12); // 10 possible digits, leading sign, null terminator
// Populate the new string
sprintf(RetString, "%d", Value);
// Return the new string
return RetString;
}
That should be enough to get you returning strings properly. Oh, and make sure you read the technical document on third-party commands before you do more - it's available on the main page of the DBPro help.