National Instruments NI-488.2 User Manual

Page 52

Advertising
background image

Chapter 4

Developing Your NI-488.2 Application

© National Instruments Corporation

4-15

NI-488.2 User Manual

long *Pibcntl;

static int(__stdcall *Pibdev)

(int ud, int pad, int sad, int tmo, int eot,

int eos);

static int(__stdcall *Pibonl)

(int ud, int v);

Pibsta = (int *) GetProcAddress(Gpib32Lib,

(LPCSTR)"user_ibsta");

Piberr = (int *) GetProcAddress(Gpib32Lib,

(LPCSTR)"user_iberr");

Pibcntl = (long *) GetProcAddress(Gpib32Lib,

(LPCSTR)"user_ibcnt");

Pibdev = (int (__stdcall *)

(int, int, int, int, int, int))

GetProcAddress(Gpib32Lib, (LPCSTR)"ibdev");

Pibonl = (int (__stdcall *)(int, int))

GetProcAddress(Gpib32Lib, (LPCSTR)"ibonl");

If

GetProcAddress

fails, it returns a NULL pointer. The following

code fragment shows you how to verify that none of the calls to

GetProcAddress

failed:

if ((Pibsta == NULL) ||

(Piberr == NULL) ||

(Pibcntl == NULL) ||

(Pibdev == NULL) ||

(Pibonl == NULL)) {

/* Free the GPIB library */

FreeLibrary(Gpib32Lib);

printf("GetProcAddress failed.");

}

Your Win32 application needs to dereference the pointer to access either
the status variables or function. The following code shows you how to call
a function and access the status variable from within your application:

dvm = (*Pibdev) (0, 1, 0, T10s, 1, 0);

if (*Pibsta & ERR) {

printf("Call failed");

}

Advertising