Справочник Пользователя для National Instruments NI-DNET

Скачать
Страница из 86
Chapter 3
Developing Your Application
3-4
ni.com
For C applications (files with 
.c
 extension), include the header file by 
adding a 
#include
 to the beginning of your code, like this:
#include "nidnet.h"
For C++ applications (files with 
.cpp
 extension), define 
_cplusplus
 
before including the header, such as:
#define _cplusplus
#include "nidnet.h"
The 
_cplusplus
 define enables the transition from C++ to the C language 
NI-DNET functions.
The reference for each NI-DNET function is provided in the NI-DNET 
Programmer Reference Manual
, which you can open from Start»All 
Programs»National Instruments»NI-DNET
.
You can find examples for Visual C++ in the 
examples
 subfolder of the 
Borland C 
folder. Each example is in a separate folder. A 
.c
 file with the 
same name as the example contains a description the example in comments 
at the top of the code.
Other Programming Languages
You can directly access NI-DNET from any programming environment 
that allows you to request addresses of functions that a dynamic link library 
(DLL) exports. The functions used to access a DLL in this manner are 
provided by the Microsoft Win32 functions of Windows. Using these 
Microsoft Win32 functions to access a DLL is often referred to as direct 
entry. To use direct entry with NI-DNET, complete the following steps:
1.
Load the NI-DNET DLL, 
nican.dll
The following C language code fragment illustrates how to call the 
Win32 
LoadLibrary
 function and check for an error.
#include <windows.h>
#include "nidnet.h"
HINSTANCE NidnetLib = NULL;
NidnetLib=LoadLibrary("nican.dll");
if (NidnetLib == NULL) {
   return FALSE; /*Error*/
}