The Fundamentals of Building Applications with NI-DAQChapter 4
PC-OPDIO-16 User Manual 4-10 © National Instruments Corporation
Example Programs
You can find some example programs and project files created in version 3.1
NIDAQWIN\BCCP_EX in the directory. Newer versions can use 3.1 project files.
Special Considerations
See Special Considerations in the Creating a Windows Application Using Borland C++ and the
Windows SDK section earlier in this chapter.
Buffer Allocation
To allocate memory, you can use the Windows functions GlobalAlloc() and
GlobalFree() or an NI-DAQ memory management function, NI_DAQ_Mem_Alloc or
NI_DAQ_Mem_Free. After allocation, to use a buffer of memory, you must lock memory with
GlobalLock() or NI_DAQ_Mem_Lock. After using the memory, you must unlock memory
with GlobalUnlock() or NI_DAQ_Mem_Unlock.
Note: If you allocate memory from GlobalAlloc(), call GlobalLock() and
GlobalPageLock() on the memory object before passing it to NI-DAQ.
Huge Buffer Access
When referencing memory buffers that may exceed 64 KB in size, use huge pointers to reference
the buffer. Any other pointer type will not perform the correct pointer increment when crossing
the 64 KB segment boundary. When you use the huge pointer, C automatically adjusts for
segment wraparound and normalizes the segment for pointer comparison.
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 the address of a
variable when you need to pass by reference.