Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Call a C DLL from VB for the USB-6008 I/O device

I am trying to make a call to a C DLL function for the USB-6008 I/O device and I keep getting an error 49 “Bad DLL calling convention”. The DLL help includes a .h file for the DLL and the function is declared as follows:

int32 DllExport __CFUNC DAQmxBaseCreateTask (const char taskName[], TaskHandle *taskHandle);

My VB code declares the function as follows:

Public Declare Function DAQmxBaseCreateTask Lib "nidaqmxbase.dll" (ByVal taskName As String, ByRef taskHandle As Long) As Long

And I make a call to the function in my VB code as follows – taskHandle is a long - :

DAQmxError = DAQmxBaseCreateTask("Test", taskHandle)
I’ve tried just about everything I can think of to make this work but I can’t seem to get it right.

Any help would be appreciated.
0 Kudos
Message 1 of 8
(12,751 Views)
The DAQmxBase DLL cannot be used directly from VB 6.0, since VB 6.0 supports calling C DLL functions that are exported using the stdcall calling convention. The DAQmxBase DLL functions use the cdecl calling convention. The only way around this for now would be to create a wrapper C DLL that basically calls these functions, but the wrapper functions are exported using the stdcalling convention. So you would need to wrap the DAQmxBase DLL. You should start by wrapping just the functions you require for your device.

We are actively pursuing improved support for programming the USB device with VB 6.0 for the future. But for now, this is the only way to set this up.
Bilal Durrani
NI
Message 2 of 8
(12,742 Views)
I m trying too to build a DLL with thisd instrument

I am using LAB VIEW 7.1 and create a simple Programm with tis NI USB 6008 Instrument.
1) initialise Task
2 Initialise Channel
3 Satrt task
4 read from to Channels (Analog 1d dbl nchan 1 samp)
stop task
clear task
My Inputs are Device name (Error in and task in are constant)
My outputs are ERRROR OUT and Data (a simple Array of double)
I only try to read the values from this shit instrument.

When I call the DLL with Lab view 71 no problem When I call this whit 61
it says fatal Error, I can t read the Data Output because it s closes automatically.
After i have to do the same with Microsoft visual basic.
Do you have tips.
I try to say NO remove Panel in VI Settings. Is it intelligent to do this for the global.vi fonctions ?
I will be very happy to have a soon answer.
0 Kudos
Message 3 of 8
(12,641 Views)
Hi damjian

You might get more help on this if you post on the LabVIEW forum. LabVIEW experts monitor those forums and might have more suggestions for you.

Thanks
Bilal Durrani
NI
0 Kudos
Message 4 of 8
(12,628 Views)
thank You for this Tip but it s brings not.
Now The vi Which call the DLL that I have built with Lab View 71 run but it s show me Error n0 -1073807346.
I dont kmow why.
When I Tried to write to the Analog Outputs with a DLL it s ok
but When I tried to read values at Port 0 it s impossible.
It s possible to build a DLL with polymorphics functions ?
0 Kudos
Message 5 of 8
(12,623 Views)

The DAQmx Base driver already comes with VI's for use with LV 7.1 or higher. So you don't really need to make a DLL for device if you want to use LV 7.1.

But I would recommend posting any LabVIEW questions to the LabVIEW forum, since this is a VB forum.

Bilal Durrani
NI
0 Kudos
Message 6 of 8
(12,590 Views)
Hello my friend:

See the solution, looking for "Programing the NI USB-6009 with visual basic 6.0"

Bye
0 Kudos
Message 7 of 8
(11,604 Views)
NI-DAQmx 7.5 (link below) now supports the USB-6008 and USB-6009 devices.  Also new to NI-DAQmx 7.5 is Visual Basic 6.0 support.  So, if you want to program one of these USB devices in VB6, I recommend installing this new driver which is much more robust and powerful than NI-DAQmx Base.  For more information on how to use NI-DAQmx in VB6, refer to https://www.ni.com/en/support/documentation/supplemental/21/using-ni-daqmx-in-text-based-programming...
 
0 Kudos
Message 8 of 8
(11,146 Views)