Click to See Complete Forum and Search --> : Wrapper combining two dlls into one


flight34
March 26th, 2008, 12:06 PM
Application Overview:

I am communicating with two identical cameras connected via Ethernet / IP.
The driver for each camera is provided as a dll.
Application programming language is LabVIEW. (LabVIEW can easily communicate with dlls using a "Called Shared Library" function).

My Approach:

To work with the two cameras at the same time it is required to create a new wrapper dll that calls the two driver dll's. I copied and uniquely named the driver dll. I then used the LoadLibrary function and the GetProcAddress to explicitly load each dll in my wrapper dll.

My Problem:

Each time I call a dll function in my wrapper dll, I need to create the objects. In other words, I am losing the handle to my objects. I need help on how to properly instantiate the objects and / or pointer to the objects. My wrapper dll is operational, but as mentioned within each function I presently need to recreate each object.

Here is some sample code from the wrapper dll to hopefully clarify:


#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
#include <conio.h> //for getch
#include "Multiple.h"




extern "C"
{
__declspec(dllexport) int wrpReadMeasurement(TMeasurement *Measurement1, TMeasurement *Measurement2)
{
CFifoWrapper Fifo1(1);
CFifoWrapper Fifo2(2);
Fifo1.pfn_FifoIpInit(0x01020304, 0x01020309, 10000);
Fifo2.pfn_FifoIpInit(0x01020305, 0x01020309, 10000);

Fifo1.pfn_FifoReadMeasurement(Measurement1);
Fifo2.pfn_FifoReadMeasurement(Measurement2);
return 0;
}

__declspec(dllexport) int wrpGetHeadSNSingle(void)
{
CFifoWrapper Fifo1(1);
Fifo1.pfn_FifoIpInit(0x01020304, 0x01020309, 10000);
return Fifo1.pfn_FifoGetHeadSN();
}
}



In the second function I want to avoid the lines:

CFifoWrapper Fifo1(1);
Fifo1.pfn_FifoIpInit(0x01020304, 0x01020309, 10000);


The code snippet below shows the section of header that loads each dll.


// constructor
CFifoWrapper::CFifoWrapper(int iInstanceNumber)
{

bComplete = false; // bComplete indicates that the constructor did not complete successfully

// load the dll
if (iInstanceNumber == 1)
hFifoHandle = LoadLibrary(_T("fifo1.dll"));
else
hFifoHandle = LoadLibrary(_T("fifo2.dll"));


if (hFifoHandle == NULL) // check error status
return; // return with bComplete = false, to indicate error status


Thank you in advance for your time and I will gladly provide more details if required.

flight34
March 27th, 2008, 09:30 PM
Just bumping my post. Any help appreciated.

Thank you, Steve.