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

Chapter 2 Shared Libraries (DLLs)

Unicode Versions and ANSI Versions of Functions

MessageBox uses one string argument. The SDK implements two versions of functions that use string arguments, a Unicode version and an ANSI version. One of the items in the Requirements section of the MessageBox documentation says, “Unicode: Implemented as Unicode and ANSI version on Windows and Windows NT.” You can distinguish the two versions in the DLL because each has a W (Unicode) or an A (ANSI) appended to the end of the function name. winuser.h contains the following code:

#ifdef UNICODE

#define MessageBox MessageBoxW

#else

#define MessageBox MessageBoxA

#endif // !UNICODE

This code defines MessageBox to be either MessageBoxA or MessageBoxW, depending on whether the application is a Unicode application. In effect, a MessageBox function does not exist in user32.dll. Instead, there is a function MessageBoxA and a function MessageBoxW. In most cases in LabVIEW, a VI programmer uses the ANSI version of the function, because the LabVIEW strings are based on ANSI, not Unicode. For this example, you use the MessageBoxA function.

Configuring a Call to the Win32 API

Now that you are familiar with many aspects of the Win32 API, you can configure a LabVIEW Call Library Function to call the MessageBox function. Remember that you must use the Standard (__stdcall) calling convention in calls to any function in the Windows SDK.

The following graphic shows a correctly configured instance of the Call Library Function. Make your Call Library Function dialog box match the settings in the graphic. Refer to the Task 1: Build the Function Prototype in LabVIEW section for a separate example that teaches you how to configure controls in Call Library Function.

© National Instruments Corporation

2-23

Using External Code in LabVIEW

Chapter 2 Shared Libraries (DLLs)

Figure 2-6. Configuring Call Library Function to call the Win32 API

You can configure the block diagram of this VI to match the following graphic.

Figure 2-7. Block Diagram for a Call to the Win32 API

Using External Code in LabVIEW

2-24

www.ni.com

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