I've been trying for a while to do this, but it just refuses to work properly for me. What I am doing is trying to pass a value to a function, and return a string from the function.
I have constructed the simplest test, and it is doing something I really don't understand. Its returning the string, but the value I pass it is coming out really wierd. Here is the C++ file:
#define DLL _declspec(dllexport)
#define UNDEC extern "C"
#include <windows.h>
#include <stdio.h>
FILE * file;
UNDEC DLL void Startup()
{
file = fopen("testfile.txt", "wt");
}
UNDEC DLL DWORD TestFunc(int value)
{
fprintf(file, "value: %i\n", value);
LPSTR returnString;
returnString = "empty";
return (DWORD)returnString;
}
Here is the resource file to compile in the dll:
#include <winresrc.h>
STRINGTABLE
BEGIN
1, "STARTUP%0%Startup"
2, "TESTFUNC[%SL%TestFunc%"
END
And here is the code I am using in DBP:
startup
print testfunc(10)
wait key
I am compiling using DevC++ (Mingw?). When I create the dll, copy it to the plugins-user folder, and run that dbp code, the it outputs a file containing the text 'value: 0'.
Anyone know what could be wrong?
"Lets migrate like bricks" - Me