National Instruments NI-CAN User Manual page 30

Table of Contents

Advertisement

© National Instruments Corporation
return FALSE;
}
Next, your application must use the Win32
get the addresses of the NI-CAN functions your application needs to use.
For each NI-CAN function used by your application, you must define a
direct entry prototype. For the prototypes for each function exported by
, refer to the NI-CAN Programmer Reference Manual. The
nican.dll
following code fragment illustrates how to get the addresses of the
,
ncOpenObject
ncCloseObject
static NCTYPE_STATUS (_NCFUNC_ *PncOpenObject)
(NCTYPE_STRING ObjName,
NCTYPE_OBJH_P ObjHandlePtr);
static NCTYPE_STATUS (_NCFUNC_ *PncCloseObject)
(NCTYPE_OBJH ObjHandle);
static NCTYPE_STATUS (_NCFUNC_ *PncRead)
(NCTYPE_OBJH ObjHandle, NCTYPE_UINT32 DataSize,
NCTYPE_ANY_P DataPtr);
PncOpenObject = (NCTYPE_STATUS (_NCFUNC_ *)
(NCTYPE_STRING, NCTYPE_OBJH_P))
GetProcAddress(NicanLib, (LPCSTR)"ncOpenObject");
PncCloseObject = (NCTYPE_STATUS (_NCFUNC_ *)
(NCTYPE_OBJH))
GetProcAddress(NicanLib, (LPCSTR)"ncCloseObject");
PncRead = (NCTYPE_STATUS (_NCFUNC_ *)
(NCTYPE_OBJH, NCTYPE_UINT32, NCTYPE_ANY_P))
GetProcAddress(NicanLib, (LPCSTR)"ncRead");
If
GetProcAddress
fragment illustrates how to verify that none of the calls to
failed:
GetProcAddress
if ((PncOpenObject
(PncCloseObject
(PncRead
FreeLibrary(NicanLib);
printf("GetProcAddress failed");
}
Your application needs to de-reference the pointer to access an NI-CAN
function, as illustrated by the following code:
NCTYPE_STATUS status;
NCTYPE_OBJH MyObjh;
Chapter 2
, and
ncRead
fails, it returns a NULL pointer. The following code
== NULL) ||
== NULL) ||
== NULL)) {
2-3
Developing Your Application
function to
GetProcAddress
functions:
NI-CAN User Manual

Advertisement

Table of Contents
loading

Table of Contents