User manual

Chapter 2 Fundamentals of Building Windows Applications
© National Instruments Corporation 2-3 NI-DAQ User Manual for PC Compatibles
Refer to the NI-DAQ Examples Help (Start»Programs»National
Instruments DAQ»NI-DAQ Examples Help) for additional information
regarding NI-DAQ examples.
Special Considerations
Buffer Allocation
To allocate memory, you can use the Windows API function
GlobalAlloc()
. After allocation, lock memory with
GlobalLock()
to use a buffer of memory. You can use the memory handle returned by
GlobalLock()
in place of the buffer parameter in NI-DAQ API functions
that accept buffers (
Align_DMA_Buffer, DAQ_DB_Transfer,
DAQ_Monitor, DAQ_Op, DAQ_Start, DIG_Block_In, DIG_Block_Out,
DIG_DB_Transfer, GPCTR_Config_Buffer, GPCTR_Read_Buffer,
Lab_ISCAN_Op, Lab_ISCAN_Start, SCAN_Op, SCAN_Start,
SCAN_Sequence_Demux, WFM_DB_Transfer, WFM_Load, WFM_Op
).
After using the memory, unlock memory with
GlobalUnlock()
and free
it with
GlobalFree()
.
Note
If you allocate memory from
GlobalAlloc()
, you must call
GlobalLock()
on
the memory object before passing it to NI-DAQ.
String Passing
To pass strings, pass a pointer to the first element of the character array.
Be sure that the string is null-terminated.
Parameter Passing
By default, C passes parameters by value. Remember to pass pointers to
variables when you need to pass by address.