Borland provide a utility IMPLIB to generate a compatible LIB file from a DLL. I have used this successfully with the K8090 for some time - see my post under the topic “information comand K8090”.
I have actually now got the K8090 and K8055 to work at the same time, without using namespaces, as follows:
- I created a copy of the K8055D_C.h file and modified the declarations for the OpenDevice() and CloseDevice() functions as follows:
FUNCTION long __stdcall K8055_OpenDevice(long CardAddress);
FUNCTION __stdcall K8055_CloseDevice();
- Based on the instructions contained at http://www.tek-tips.com/viewthread.cfm?qid=1099123&page=23
2a) I created a DEF file from the K8055 DLL using the command:
IMPDEF K8055D2.DEF K8055D.DLL
2b) I modified the resulting DEF file to add aliased copies of the OpenDevice() and CloseDevice() functions so that the resulting file looked like this:
[code]LIBRARY K8055D.DLL
EXPORTS
ClearAllAnalog @1 ; ClearAllAnalog
ClearAllDigital @2 ; ClearAllDigital
ClearAnalogChannel @3 ; ClearAnalogChannel
ClearDigitalChannel @4 ; ClearDigitalChannel
CloseDevice @5 ; CloseDevice
OpenDevice @6 ; OpenDevice
OutputAllAnalog @7 ; OutputAllAnalog
OutputAnalogChannel @8 ; OutputAnalogChannel
ReadAllAnalog @9 ; ReadAllAnalog
ReadAllDigital @10 ; ReadAllDigital
ReadAnalogChannel @11 ; ReadAnalogChannel
ReadCounter @12 ; ReadCounter
ReadDigitalChannel @13 ; ReadDigitalChannel
ResetCounter @14 ; ResetCounter
SearchDevices @15 ; SearchDevices
SetAllAnalog @16 ; SetAllAnalog
SetAllDigital @17 ; SetAllDigital
SetAnalogChannel @18 ; SetAnalogChannel
SetCounterDebounceTime @19 ; SetCounterDebounceTime
SetCurrentDevice @20 ; SetCurrentDevice
SetDigitalChannel @21 ; SetDigitalChannel
Version @22 ; Version
WriteAllDigital @23 ; WriteAllDigital
K8055_CloseDevice = CloseDevice
K8055_OpenDevice = OpenDevice
[/code]
2c) I then created a Borland compatible LIB file from the modified DEF file using the command:
IMPLIB K8055D2.LIB K8055D2.DEF
and added the resulting LIB file to my project along with the previously created K8090D.lib file.
The following code now works without the need for namespaces:
[code]#include <windows.h>
#include <stdio.h>
#include “K8090D.h” // Velleman Relay board
#include “K8055D2.h” // Velleman USB interface board
#define K8055_CARD_ADR 0 // card address for USB interface board
//---------------------------------------------------------------------------
int PulseChannel8()
{
int return_value = 1; // set return_value for fail by default
int result;
result = K8055_OpenDevice(K8055_CARD_ADR);
if(result == K8055_CARD_ADR)
{
SetDigitalChannel(8);
Sleep(1000);
ClearDigitalChannel(8);
K8055_CloseDevice();
return_value = 0;
}
else
printf(“Unable to connect to K8055 USB interface board.\n”);
return return_value;
}
//---------------------------------------------------------------------------
int PulseRelay8()
{
HK8090 hRelay; // handle to K8090 relay board
int return_value = 1; // set return_value for fail by default
hRelay = OpenDevice(“COM5”);
if ((hRelay != NULL) && (hRelay != INVALID_HANDLE_VALUE))
{
SendCommand(hRelay, CMD_SWITCH_RELAY_ON, 0x80, 0x00, 0x00);;
Sleep(1000);
SendCommand(hRelay, CMD_SWITCH_RELAY_OFF, 0x80, 0x00, 0x00);
CloseDevice(hRelay);
return_value = 0;
}
else
printf(“Unable to connect to K8090 relay board.\n”);
return return_value;
}
//---------------------------------------------------------------------------
int main(int argc, char* argv[])
{
int result;
while(TRUE)
{
result = PulseRelay8();
printf(“8090: %d\n”, result);
getc(stdin);
result = PulseChannel8();
printf(“8055: %d\n”, result);
getc(stdin);
}
return 0;
}
[/code]
Why it wouldn’t work using namespaces I don’t know.