Posted: 18th Feb 2004 10:40
This is a very old code bit.
Just thought some ppl who want to make DLL's might like this. It's C++ code showing how to return different results.

+ Code Snippet
//
// DarkDLLCore Source Code Example
//

// Lets the compiler know DARKDLL Functions are to be seen by DarkBASIC
#define DARKDLL __declspec(dllexport)

// Standard Includes
#include "windows.h"
#include "stdio.h"

// Use this function to handle loading and freeing of the DLL
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
	{
		case DLL_PROCESS_ATTACH:
			// When DLL Is loaded - prompt
			MessageBox(NULL, "DLL_PROCESS_ATTACH", "DllMain", MB_OK);
			break;

		case DLL_PROCESS_DETACH:
			// When DLL Is released - prompt
			MessageBox(NULL, "DLL_PROCESS_DETACH", "DllMain", MB_OK);
			break;
    }
    return TRUE;
}

// No Data In, No Data Out
DARKDLL void SimpleFunction(void)
{
	// Prompt
	MessageBox(NULL, "Hello World", "Simple Function", MB_OK);
}

// DataIn: INTEGER  DataOut: INTEGER
DARKDLL DWORD FunctionReturnInteger(int DataIn)
{
	// Prompt
	char str[256];
	sprintf(str,"Function has received the Integer value of %d", DataIn);
	MessageBox(NULL, str, "FunctionReturnInteger", MB_OK);

	// Prepare an INTEGER and return as a DWORD
	int DataOut = 11;
	return *((DWORD*)&DataOut);
}

// DataIn: FLOAT  DataOut: FLOAT
DARKDLL DWORD FunctionReturnFloat(float DataIn)
{
	// Prompt
	char str[256];
	sprintf(str,"Function has received the Float value of %f", DataIn);
	MessageBox(NULL, str, "FunctionReturnFloat", MB_OK);

	// Prepare a FLOAT and return as a DWORD
	float DataOut = 22.2f;
	return *((DWORD*)&DataOut);
}

// To export a string from a DLL, the string must be global
static char gGlobalDataString[256];

// DataIn: STRING  DataOut: STRING
DARKDLL DWORD FunctionReturnString(char* DataIn)
{
	// Prompt
	char str[256];
	sprintf(str,"Function has received the String value of %s", DataIn);
	MessageBox(NULL, str, "FunctionReturnString", MB_OK);

	// Prepare a STRING and return as a DWORD POINTER
	strcpy(gGlobalDataString, "HELLO WORLD!!");
	return (DWORD)(DWORD*)gGlobalDataString;
}


And for someone like me, I found the bit about how to return a string useful.
Posted: 24th Feb 2004 23:49
uhhhh....isnt this like....a darkbasic thingie?
Posted: 25th Feb 2004 7:03
the code shows how to make a dll compatible with darkbasic
Posted: 25th Feb 2004 8:00
Does it work with DBC? I tried using call dll 1,SimpleFunction but it keeps failing. I compiled the DLL using mingw
Posted: 26th Feb 2004 8:06
not sure. I think maybe classic was a little different with dll's. i dont really know.
Posted: 27th Feb 2004 15:49
If someone would have the same kind of very simple example in Virtual Basic 5.0. I would be most grateful.

I am trying to compile a dll in VB5.0 source to unse it into DBPro. Success is not guaranteed...

Thanks.
Posted: 5th Mar 2004 16:16
You can't make DB compatible DLL's with VisualBasic, if that's what you're talking about. I've never heard of "VirtualBasic".
Posted: 5th Mar 2004 17:01
Some people (I think Exeat was one) made a wrapper for VB Dlls. Check out the Darkbasic Professional forum, its in there somewhere iirc.
Posted: 5th Mar 2004 17:11
Yeah, I tried that, but I felt it was more work than simply making the DLL in VC++.