BNC 645 User Manual
Page 189

189
//standard include for a Microsoft Visual C++ project
#include "stdio.h"
//need for COM
#include "windows.h"
#include "comdef.h"
//This is the 'Automation' object (COM class). It contains the IIOManger interface
//below
const CLSID CLSID_BERKELEY NUCLEONICS CORPORATIONIOUtils =
{0xCF1DC41A,0x5E37,0x455E,{0xA3,0x88,0x17,0xB9,0x20,0x14,0x04,0xB1}};
//The IIO allows the opening of a device using its address in the 'ConnectToInstrument'
function. The IO
//class above exports this
//COM interface.
Continued on next page
//The IIO function 'ConnectToInstrument' will return the IIO interface
//this is an instance of the instrument.
const IID IID_IOUtils=
{0x3E0AC3A2,0xB527,0x4741,{0x8D,0x3E,0x83,0xC8,0x13,0x59,0xA5,0xC6}};
//The following are the definitions needed to program the instrument. They
//can be placed in a header file for but are shown here to allow ease of
//perusal
/***************************************************************************/
//This definition is to complete the IIO interface below. You needn't use this interface
directly to
//communicate with instruments
extern "C" {
interface IIOUtils : IDispatch {
STDMETHOD (Count)(short *pVal);
STDMETHOD (TimeOut)(short *pVal);
STDMETHOD (TimeOut)(short newVal);
STDMETHOD (Open)(void);
STDMETHOD (Close)(void);
STDMETHOD (Refresh)(void);
STDMETHOD (Index)(short newVal);
STDMETHOD (Index)(short *pVal);
STDMETHOD (Output)(BSTR newVal);
STDMETHOD (Input)(BSTR *pVal);
STDMETHOD (Address)(BSTR *pVal);
STDMETHOD (Query)(BSTR newValue, BSTR *pVal);
STDMETHOD (ErrFlag)(long *pVal);
STDMETHOD (Connect)(BSTR newVal);
};
}//extern "C"
/****************************************************************************/
int main(int argc, char* argv[])
{
IIOUtils *IIO; //The IO we'll be using to get to the instrument
HRESULT hr;
//check return values for failure
_variant_t
myCmd;
_variant_t
myResult;
_bstr_t
myInstrument,strTmp;
BSTR
bstr;
printf("Start CExample program. We assume a Model 645 multimeter on