136
Visual C++
This C++ sample application is a Win32 console application. It illustrates how to use the TEXIO IOUtils
command. A Win32 console application is a Win32 application that uses text-based input and output, not
a graphical interface. This allows you to quickly create a Win32 application by using simple input and
output functions.
C.3 THE DEVQUERY FUNCTION
LISTING C.3.
After the path
C:\Program Files\IVI Foundation\VISA\WinNT\include
has been entered,
you have to add an
“
Include
”
path.
Add C:\WINDOWS\system32\
visa32.dll
to Project folder.
// devquery.cpp : Defines the entry point for the console application.
//
// Call the NI-VISA library visa32.dll
//
//
#include "stdafx.h"
#include "visa.h"
//standard include for a Microsoft Visual C++ project
#include "stdio.h"
#include "windows.h"
void main(int argc, char* argv[])
{
// TODO: Add your control notification handler code here
HINSTANCE hUSBTMCLIB; // for USBTMC HANDLE
unsigned long m_defaultRM_usbtmc, m_instr_usbtmc;
unsigned long m_findList_usbtmc;
unsigned long m_nCount;
ViStatus status;
int m_Timeout = 7000;
char *pStrout; // Write out data buffer
BYTE pStrin[64]; // Read in data buffer
int len;
ULONG nWritten;
ULONG nRead = 0;
char buffer[256];
char instrDescriptor[256];
// Load the NI-VISA library for USBTMC device
hUSBTMCLIB = LoadLibrary ("visa32.dll");
if (!hUSBTMCLIB)
{
MessageBox(NULL, "NIVISA for USBTMC library not found.", "DL-1060 multimeter device test", MB_OK);
return;
}
// Link the libraries
signed long (__stdcall *PviOpenDefaultRM_usb) (unsigned long *vi);
signed long (__stdcall *PviFindRsrc_usb) (unsigned long sesn, char *expr, unsigned long *vi,