Chapter 3
Developing Your Application
©
National Instruments Corporation
3-5
2.
Get the addresses for the NI-DNET DLL functions you will use.
Your application must use the Win32
GetProcAddress
function to
get the addresses of the NI-DNET functions your application needs.
For each NI-DNET function used by your application, you must define
a direct entry prototype. For the prototypes for each function exported
by
nican.dll
, refer to the
NI-DNET Programmer Reference Manual
.
The following code fragment illustrates how to get the addresses of the
ncOpenDnetIO
,
ncCloseObject
, and
ncReadDnetIO
functions.
static NCTYPE_STATUS (_NCFUNC_ *PncOpenDnetIO)
(NCTYPE_STRING ObjName,
NCTYPE_OBJH_P ObjHandlePtr);
static NCTYPE_STATUS (_NCFUNC_ *PncCloseObject)
(NCTYPE_OBJH ObjHandle);
static NCTYPE_STATUS (_NCFUNC_ *PncReadDnetIO)
(NCTYPE_OBJH ObjHandle, NCTYPE_UINT32 SizeofData,
NCTYPE_ANY_P Data);
PncOpenDnetIO = (NCTYPE_STATUS (_NCFUNC_ *)
(NCTYPE_STRING, NCTYPE_OBJH_P))
GetProcAddress(NidnetLib,
(LPCSTR)"ncOpenDnetIO");
PncCloseObject = (NCTYPE_STATUS (_NCFUNC_ *)
(NCTYPE_OBJH))
GetProcAddress(NidnetLib,
(LPCSTR)"ncCloseObject");
PncRead = (NCTYPE_STATUS (_NCFUNC_ *)
(NCTYPE_OBJH, NCTYPE_UINT32, NCTYPE_ANY_P))
GetProcAddress(NidnetLib,
(LPCSTR)"ncReadDnetIO");
If
GetProcAddress
fails, it returns a NULL pointer. The following
code fragment illustrates how to verify that none of the calls to
GetProcAddress
failed.
if ((PncOpenDnetIO == NULL) ||
(PncCloseObject == NULL) ||
(PncReadDnetIO == NULL)) {
FreeLibrary(NidnetLib);
printf("GetProcAddress failed");
}