User`s guide
Programming with VISA 3
Agilent VISA User’s Guide 73
status = viOpenDefaultRM( &drm );
if ( status < VI_SUCCESS ) {
printf( "ERROR: viOpenDefaultRM failed with
error = 0x%lx\n", status );
return;
}
/* Install the exception handler and enable
events for it */
status = viInstallHandler(drm,
VI_EVENT_EXCEPTION, myExceptionHandler,
myUserHandle);
if ( status < VI_SUCCESS )
{
printf( "ERROR: viInstallHandler failed
with error 0x%lx\n", status );
}
status = viEnableEvent(drm, VI_EVENT_EXCEPTION,
VI_HNDLR, VI_NULL);
if ( status < VI_SUCCESS ) {
printf( "ERROR: viEnableEvent failed with
error 0x%lx\n", status );
}
/* Generate an error to demonstrate that the
handler will be called */
status = viOpen( drm, "badVisaName", NULL,
NULL, &vi );
if ( status < VI_SUCCESS ) {
printf("ERROR: viOpen failed with error
0x%lx\n"
"Exception Handler should have been
called\n"
"before this message was printed.\n",status
);
}
}