Solution
Note: NI-DAQmx Base is compatible with macOS 10.14 and earlier versions and starting 2018, NI-DAQmx for Linux is included with the NI Linux Device Drivers. Please check compatibility for Windows, Linux, and
macOS for supported versions of this driver. For more information, please read the End-of-Life Announcement for DAQmx Base Driver.You can call DAQmx Base functions in these languages. However, DAQmx Base is only officially supported in LabVIEW and C. Because of this, you'll need to directly call the DAQmx Base DLL if you plan to use a different language. The following examples demonstrate calling the DAQmx Base DLL directly.
[C#]
using System;
using System.Runtime.InteropServices;
using TaskHandle = System.UInt32;
public class LibWrap
{
// C# doesn't support varargs so all arguments must be explicitly defined.
// CallingConvention.Cdecl must be used since the stack is
// cleaned up by the caller.
[DllImport("nidaqmxbase.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int DAQmxBaseCreateTask (
string taskName, out TaskHandle taskHandle);
[DllImport("nidaqmxbase.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int DAQmxBaseCreateAIThrmcplChan (
TaskHandle taskHandle, string physicalChannel,
string nameToAssignToChannel, double minVal, double maxVal,
int units, int thermocoupleType, int cjcSource, double cjcVal,
string cjcChannel);
}
public class App
{
public static void Main()
{
TaskHandle taskHandle;
LibWrap.DAQmxBaseCreateTask("", out taskHandle) );
LibWrap.DAQmxBaseCreateAIThrmcplChan(taskHandle, "/Dev1/ai0", "", 0,
10, DAQmx_Val_DegC, DAQmx_Val_K_Type_TC,
DAQmx_Val_BuiltIn, 0, "") );
}
}
[VB .NET]
Imports System
Imports Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Imports TaskHandle = System.UInt32
Public Class LibWrap
' Visual Basic does not support varargs, so all arguments must be
' explicitly defined. CallingConvention.Cdecl must be used since the
' stack is cleaned up by the caller.
<DllImport("nidaqmxbase.dll", CallingConvention:= _
CallingConvention.Cdecl)> Public Shared Function _
DAQmxBaseCreateTask(ByVal taskName As String, _
ByRef taskHandle As TaskHandle) As Integer
End Function
<DllImport("nidaqmxbase.dll", CallingConvention := _
CallingConvention.Cdecl)> Public Shared Function _
DAQmxBaseCreateAIVoltageChan(ByVal taskHandle _
As TaskHandle, ByVal physicalChannel As String, _
ByVal nameToAssignToChannel As String, ByVal terminalConfig _
As Integer, ByVal minVal As Double, ByVal maxVal As Double, _
ByVal units As Integer, ByVal customScaleName As String) _
As Integer
End Function
End Class 'LibWrap
Public Class App
Public Shared Sub Main()
Dim taskHandle As TaskHandle = Convert.ToUInt32(0)
LibWrap.DAQmxBaseCreateTask("", taskHandle)
LibWrap.DAQmxBaseCreateAIVoltageChan(taskHandle, "/Dev1/ai0", "", _
DAQmx_Val_Cfg_Default, 0, 10, DAQmx_Val_Volts, Nothing)
End Sub 'Main
End Class 'App
[VB 6.0]The DAQmx Base DLL cannot be directly called from VB 6.0, because the DLL exports functions using the cdecl calling convention. VB 6.0 only supports stdcall. The only way to get around this is to create a wrapper C DLL that calls the functions using cdecl and exports them again using stdcall. A wrapper C DLL for DAQmx Base 1.5 and a simple example demonstrating how to use it are attached. Please follow the instructions of README.txt before running the example.