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

Chapter 2 Shared Libraries (DLLs)

Caution Do not attempt to resize a string with system functions, such as realloc. Doing so might crash your system.

Waveform—For waveform data types, you indicate the dimension, and you use the Data Type pull-down menu to indicate the exact numeric type.

ActiveX—For ActiveX objects, you select one of the following items in the

Data Type pull-down menu:

ActiveX Variant Pointer—Passes a pointer to ActiveX data.

IDispatch* Pointer—Passes a pointer to the IDispatch interface of an ActiveX Automation server.

IUnknown Pointer—Passes a pointer to the IUnknown interface of an ActiveX Automation server.

Adapt to Type—Pass arbitrary LabVIEW data types to DLLs in the same way they are passed to a CIN, as follows:

Scalars are passed by reference. A pointer to the scalar is passed to the library.

Arrays and strings are passed as a handle (pointer to a pointer to the data).

Clusters are passed by reference.

Scalar elements in arrays or clusters are in line. For example, a cluster containing a numeric is passed as a pointer to a structure containing a numeric.

Cluster within arrays are in line.

Strings and arrays within clusters are referenced by a handle.

Calling Functions That Expect Other Data Types

You might encounter a function that expects a data type LabVIEW does not use. For example, you cannot use Call Library Function to pass an arbitrary cluster or array of non-numeric data. If you need to call a function that expects other data types, use one of the following methods:

Depending on the data type, you might be able to pass the data by creating a string or array of bytes that contains a binary image of the data you want to send. You can create binary data by typecasting data elements to strings and concatenating them.

Write a library function that accepts data types that LabVIEW does use, and parameters to build the data structures the library function expects, then calls the library function.

© National Instruments Corporation

2-5

Using External Code in LabVIEW

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