Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Using External Code in LabVIEW.pdf
Скачиваний:
49
Добавлен:
29.05.2015
Размер:
1.85 Mб
Скачать

Chapter 2 Shared Libraries (DLLs)

The name you specify in the LIBRARY statement identifies the library in the import library of the DLL.

The names you specify in the EXPORTS statement identify the functions that the DLL exports.

Note Instead of a .def file, many Windows programmers use the LINK option in Project Settings of the Visual C++ compiler to obtain equivalent command-line options for most module definition statements.

Array and String Options

This section reviews important concepts regarding array and string data in

Call Library Function.

Arrays of Numeric Data

Arrays of numeric data can be comprised of any type of integers, or floating point numbers with single (4-byte) or double (8-byte) precision. When you pass an array of data to a DLL function, you can pass the data as an Array Data Pointer, as a LabVIEW Array Handle, or as a LabVIEW Array Handle Pointer.

The following list presents the characteristics of Array Data Pointers, whether you pass them in the Windows API or in another API. Remember that the Windows API does not use LabVIEW array handles, so with functions that are part of the Windows API you can use only Array Data Pointers.

You can set the number of dimensions in the array, but you must not include information about the size of the array dimension(s). Instead, you must pass the size of the array dimension(s) information to your DLL in a separate variable.

Specifically, never resize an array or perform operations that may change the length of the array data passed from LabVIEW. Resizing may cause a crash because the pointer sent is not an allocated block, but rather, points into the middle of an allocated block.

To return an array of data, you should allocate an array of sufficient size in LabVIEW, pass it to your function, and have this array act as the buffer. If the data takes less space, you can return the correct size as a separate parameter and then, on the calling diagram, use array subset to extract the valid data.

Using External Code in LabVIEW

2-30

www.ni.com

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]