Hi all,
I am using code::blocks (MinGW) and I can't get this function to be seen by DBP when using my dll.
I read all explanations given for DevC++ from this topic :
http://forum.thegamecreators.com/?m=forum_view&t=55588&b=18 and I tried to use the same approach with code::blocks but the IDE seems to manage things in a different way : linking with a .def file doesn't make my dll to work.
There's no errors with the compilation of my dll but I know the core is not available because I'am using the following code (which always returns the "Core not set" message when calling my function from DBP) :
if (!g_pGlob) MessageBox(0, "Core not set", "", MB_OK);
Here is a part of the dll code (I removed all the functions except the one that need the core):
#include <windows.h>
#include <vector>
#include <string.h>
#include <iostream>
#include <fstream>
#define EXPORT __declspec (dllexport)
// Include Core (optional)
#include "globstruct.h"
GlobStruct* g_pGlob = NULL;
EXPORT void Constructor ( void )
{
// Create memory here
}
EXPORT void Destructor ( void )
{
// Free memory here
}
EXPORT void ReceiveCoreDataPtr ( LPVOID pCore )
{
// Get Core Data Pointer here
g_pGlob = (GlobStruct*)pCore;
}
using namespace std;
//-----------------------------------------------------//
// I removed all the functions that don't use the core //
//-----------------------------------------------------//
EXPORT DWORD PrintString(DWORD pOldString)
{
if (!g_pGlob) MessageBox(0, "Core not set", "", MB_OK);
char *NewString = "Hello World, this is my DLL function text!";
// Return string pointer
LPSTR pReturnString=NULL;
// Create a new string and copy input string to it
DWORD dwSize=strlen( (LPSTR) NewString );
g_pGlob->CreateDeleteString ( (DWORD*)&pReturnString, dwSize+1 );
strcpy(pReturnString, (LPSTR) NewString);
// Delete old string: I placed the delete code here to avoid an error with calls like "A$ = MyFunction (A$)"
if(pOldString) g_pGlob->CreateDeleteString ( (DWORD*)&pOldString, 0 );
// Return new string pointer
return (DWORD)pReturnString;
}
And here is the Stringtable:
STRINGTABLE
{
1 "CUBE[%LL%_Z4Cubei%"
2 "SQUARE[%LL%_Z6Squarei%"
3 "GET VALUE[%L%_Z8GetValuev%"
4 "SCAN ALPHA[%L%_Z8ScanAlphav%"
5 "GETWINDOWHANDLE[%L%_Z15GetWindowHandlev%"
6 "MESSAGEBOX[%LSSL%_Z11MessageBoxAPcS_i%"
7 "OPENFILEBOX[%LS%_Z11OpenFileBoxPc%"
8 "PRINTSTRING[%SS%_Z11PrintStringm%"
}
These are the original files of my dll, I don't post the modified versions I made of the stringtable and the .def file as they don't work much more.
Any help or comment is welcome to get the core to be "seen".
Thanks!
Chris