Function specifications
Win32API format
* Not compatible with Universal Windows Platform (UWP).
Function parameters and return value
The contents of the parameters and the return
value of functions are common regardless of the development language.
Please refer to the function reference for details.
Format of function reference
Visual Basic .NET has a different data type
than previous versions of Visual Basic 5.0 and 6.0.
Please be careful when using the application created in the old version.
Note of using callback function
When notifying an event by using callback
function in Visual Basic .NET,
it is required to fix the callback function's memory address.
The following code is the sample to process
an count match event.
For details, please refer to the sample programs.
■ Declaring as global variables.
Dim gCh As GCHandle
Dim pdelegate_func As PCOUNTUPCALLBACK
Dim pfunc As IntPtr
■ In the Load method, initializing the delegate for interrupt process, and add a reference to prevent garbage collection from being destroyed.
pdelegate_func = New PCOUNTUPCALLBACK(AddressOf
CallBackProc)
gCh = GCHandle.Alloc(pdelegate_func)
■ In the Close method, releasing the handle.
gCh.Free()
■ Retrieving the fixed function pointer.
pfunc = Marshal.GetFunctionPointerForDelegate(pdelegate_func)
■ Specifying the retrieved fixed pointer by function CntCountUpCallbackProc.
Ret = CntCountUpCallbackProc(Id, pfunc, Temp)
Note of using CntSamplingSetBuffer()
In Visual Basic .NET, for the buffer used
for bus master transfer, it is required to add process for fixing memory
address.
The following code is the sample for this process.
For details, please refer to the sample programs.
■ Declaring as global variables.
Public Const CHANNEL_NUM As
Short = 4
Public Const DATA_NUM As Short = 1000
Dim gCh As GCHandle
Dim pSamplingData As IntPtr
Dim SampData(DATA_NUM - 1, CHANNEL_NUM - 1) As Integer
■ In the Load method, assigning a handle of Pinned type to the buffer.
If gCh.IsAllocated = False Then
gCh = GCHandle.Alloc(SampData, GCHandleType.Pinned)
End If
■ In the Closed method, releasing the handle.
If gCh.IsAllocated = True Then
gCh.Free()
End If
■ Retrieving the pointer of fixed object.
Buf = gCh.AddrOfPinnedObject()
■ Specifying the retrieved fixed pointer by function CntSamplingSetBuffer.
dwRet = CntSamplingSetBuffer(Id, pSamplingData, CHANNEL_NUM, DATA_NUM, CNTS_WRITE_ONCE)