lib files compiler specific?

Started by
21 comments, last by darookie 19 years, 8 months ago
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 ExplicitPrivate Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As LongPrivate Declare Sub CloseDevice Lib "k8055d.dll" ()Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As LongPrivate 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 AsLong)Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 AsLong)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) AsBooleanPrivate Declare Function ReadAllDigital Lib "k8055d.dll" () As LongPrivate Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Long) As LongPrivate Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Long)Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Long, ByValDebounceTime As Long)
Advertisement
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
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]
Well I changed long to int but it still crashes if I use the SeDigitalOutput command a couple of times.
Wheres the damn memory error. Something isnt declared correctly yet.

-CProgrammer
In VB, if you see ByRef - take that to mean a pointer. If it's ByVal, just use the straight value. Long == int, Short == short, Byte == unsigned char
Thanks for the tip but its still crashing.
It must be some detail thing in my declaration.

-CProgrammer
//Listing K8055D.h#ifdef __cplusplusextern "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?
I only declared the functions Im actually using.
They are declared as I posted a couple posts back.

-CProgrammer
Sorry I can't help you more [sad]

One thing I find interesting though is that the document (user manual) I linked before doesn't talk about SetDigitalOutput at all. Weird.
Yes very strange. Well thanks for stinking with me so long.

Maybe Ill just write an interface in borland c++ and try to include that.

-CProgrammer

This topic is closed to new replies.

Advertisement