Explicit Loading of BB DLL

From: Danforth, Douglas <"Danforth,>
Date: Fri, 6 Apr 2001 10:47:02 -0400

Folks,

In the interim of finding a clean 'implicit' loading of DLLs
created by BlackBox for the C programmer I am using 'explicit'
loading. The following is a concrete example a real project
here at QuikCAT.com.

Principals followed:
o Reduce work for user of DLL by specifying everything needed
  within a C header file for the DLL.
o Put all LoadLibrary and GetProcAddress calls withn a single
  procedure, MyDllInit(), which is defined in the header.
o Create a MyDllFini() that does FreeLibray to release the
  DLL.
o Make all procedure (variables) global to the
  file that includes the header by using static and qualified
  names, i.e. MyDllProc1, so no name clashes result.
o Tell the user to call MyDllInit first and only once.
o Tell the user to call MyDllFini last and only once.

Example header (I'm sure you know all this but what the heck)

#ifndef __QcOnePassArrays__
#define __QcOnePassArrays__
#include <windows.h>

typedef (CALLBACK* OPA_ENCODE)(int len, int* x, unsigned char* c, int tol);
typedef (CALLBACK* OPA_DECODE)(int len, int* x, unsigned char* c);

static OPA_ENCODE OpaEncode;
static OPA_DECODE OpaDecode;
static HINSTANCE opaDll;

void OpaInit()
{
        opaDll = LoadLibrary("OpaBB.dll");
        if(opaDll != NULL)
        {
                OpaEncode = (OPA_ENCODE)GetProcAddress (opaDll, "Encode");
                OpaDecode = (OPA_DECODE)GetProcAddress (opaDll, "Decode");
        }
};

void OpaFini()
{
        OpaEncode = NULL;
        OpaDecode = NULL;
        FreeLibrary(opaDll); opaDll = 0;
};

#endif


-Doug

---
Douglas G. Danforth, Ph.D. - Research Scientist
QuikCAT.com   6700 Beta Drive,  Suite 200,  Mayfield Village,  OH 44143-2335
danforth{([at]})nowhere.xy--------------------------------------------
To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xyTo get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.
Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy
Received on Fri Apr 06 2001 - 14:47:02 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:44 UTC