How can i run a DLL?

BlitzMax Forums/BlitzMax Beginners Area/How can i run a DLL?

I got it to work by making a c wrapper, just do something like this in a c file

#include "windows.h"

#define BBCALL _stdcall

const void BBCALL (*PGfxInit) ( void );

byte * DredGetProcAddress ( HINSTANCE lib, char * fname )
{
   byte * ptr;

   ptr =  GetProcAddress ( lib, fname );

   if ( ptr == NULL ) 
   {
       printf ("\nNULL: %s\n", fname );
       fflush(NULL);
   }

   return(ptr);
}

void DredInitDll ( void )
{
   HINSTANCE lib;

   lib = LoadLibraryA (TEXT("dred") );
   PGfxInit = DredGetProcAddress ( lib, "GfxInit@0");
}

// =========================
void GfxInit ( void )
{
   PGfxInit();
}



Then do the nessesary externs in bmx , import the c file in bmx.. call the dll init then the wrapper functions ( like GfxInit ). maybe there is another way ? but i couldnt get anything else to work.