Sign in to follow this  
CProgrammer

lib files compiler specific?

Recommended Posts

K8055.dll usermanual

That may be of help. There's a VB section towards the end with the paramters info. You might be able to write your own interface?


Option Explicit
Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long
Private Declare Sub CloseDevice Lib "k8055d.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As Long
Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (Data1 As Long, Data2 As Long)
Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long, ByVal Data As
Long)
Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 As
Long)
Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long)
Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long) As
Boolean
Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Long
Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Long) As Long
Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Long)
Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Long, ByVal
DebounceTime As Long)

Share this post


Link to post
Share on other sites
I have tryed to make an interface but it seems the VB version is detailed and could really help. The thing is I dont know VB. Could you have a look at my interface and tell me what could be causing the crashes.

Edit: Looked up SUB. I guess im missing a virtual command in my interface?

Here it is:


long __stdcall OpenDevice(long CardAddress);
typedef long (*OPENDEVICE)(long CardAddress);

void __stdcall CloseDevice();
typedef void (*CLOSEDEVICE)();

void __stdcall ClearDigitalChannel(long Channel);
typedef void (*CLEARDIGITALCHANNEL)(long Channel);

void __stdcall SetDigitalChannel(long Channel);
typedef void (*SETDIGITALCHANNEL)(long Channel);

void __stdcall OutputAnalogChannel(long Channel, long Data);
typedef void (*OUTPUTANALOGCHANNEL)(long Channel, long Data);

void __stdcall ClearAnalogChannel(long Channel);
typedef void (*CLEARANALOGCHANNEL)(long Channel);

HMODULE dll;

OPENDEVICE KOpenDevice;
CLOSEDEVICE KCloseDevice;
CLEARDIGITALCHANNEL KClearDigitalChannel;
SETDIGITALCHANNEL KSetDigitalChannel;
OUTPUTANALOGCHANNEL KOutputAnalogChannel;
CLEARANALOGCHANNEL KClearAnalogChannel;

//and in main
dll = LoadLibraryEx("k8055D.dll", NULL, 0);
if(!dll)
{
cout<<"dll not loaded"<<endl;
}
KOpenDevice = (OPENDEVICE)GetProcAddress(dll, "OpenDevice");
if(!KOpenDevice)
{
cout<<"load prob"<<endl;
}

KCloseDevice = (CLOSEDEVICE)GetProcAddress(dll, "CloseDevice");
KClearDigitalChannel = (CLEARDIGITALCHANNEL)GetProcAddress(dll, "ClearDigitalChannel");
KSetDigitalChannel = (SETDIGITALCHANNEL)GetProcAddress(dll, "SetDigitalChannel");
KOutputAnalogChannel = (OUTPUTANALOGCHANNEL)GetProcAddress(dll, "OutputAnalogChannel");
KClearAnalogChannel = (CLEARANALOGCHANNEL)GetProcAddress(dll, "ClearAnalogChannel");


Thanks a bunch

-CProgrammer

Share this post


Link to post
Share on other sites
Quote:
Original post by evolutional
You might be able to write your own interface?

Exactly. Way to go!
You need to dynamically load your DLL and setup function pointers
using GetProcAddress(). Since you have all the prototypes, this
ought to be no problem at all.

Cheers,
Pat

[EDIT]You already did it [smile] - try to change long to int - BTW, don't you have a C/C++ header file, too?
You should use the declarations from there and just add function
pointer definitions to the functions, as you already did.
[/EDIT]

Share this post


Link to post
Share on other sites

//Listing K8055D.h
#ifdef __cplusplus
extern "C" {
#endif
#define FUNCTION __declspec(dllimport)
FUNCTION long __stdcall OpenDevice(long CardAddress);
FUNCTION __stdcall CloseDevice();
FUNCTION long __stdcall ReadAnalogChannel(long Channel);
FUNCTION __stdcall ReadAllAnalog(long *Data1, long *Data2);
FUNCTION __stdcall OutputAnalogChannel(long Channel, long Data);
FUNCTION __stdcall OutputAllAnalog(long Data1, long Data2);
FUNCTION __stdcall ClearAnalogChannel(long Channel);
FUNCTION __stdcall ClearAllAnalog();
FUNCTION __stdcall SetAnalogChannel(long Channel);
FUNCTION __stdcall SetAllAnalog();
FUNCTION __stdcall WriteAllDigital(long Data);
FUNCTION __stdcall ClearDigitalChannel(long Channel);
FUNCTION __stdcall ClearAllDigital();
FUNCTION __stdcall SetDigitalChannel(long Channel);
FUNCTION __stdcall SetAllDigital();
FUNCTION bool __stdcall ReadDigitalChannel(long Channel);
FUNCTION long __stdcall ReadAllDigital();
FUNCTION long __stdcall ReadCounter(long CounterNr);
FUNCTION __stdcall ResetCounter(long CounterNr);
FUNCTION __stdcall SetCounterDebounceTime(long CounterNr, long DebounceTime);
#ifdef __cplusplus
}
#endif



Do you have the functions hooked correctly? And is it the correct version of the Library?

Share this post


Link to post
Share on other sites
This perfectly demonstrates why file extensions are stupid, and why the world will be a better place when they finally die. In this case, both compilers use the same extension, but the formats are different; so, the extension fails to communicate the type accurately.

Share this post


Link to post
Share on other sites
Quote:
Original post by evolutional
I remember seeing that argument in the late 1980's when EA and Commodore developed the Interchange File Format (IFF) file format. It never realy made it further than images and sound before it died along with Commodore :(

Not really.
The IFF format is pretty widespread even though developers usually
use custom file extensions. If you take a look at some game resource files you will notice that many use the IFF chunk format, (I use it, too) while the extension varies.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this