在VC 60中给的例程如下
#include <stdio.h> /* used for printf() */
#pragma warning( push )
#pragma warning( disable : 4192 )
#pragma warning( disable : 4786 )
#include <comdef.h> /* used for Native C++ compiler COM support */
#include <conio.h> /* used for getch */
// import IO library
#import "C:/Program Files/Common Files/Agilent/IOLibraries/AgtIOUtils.dll"
#pragma warning( pop )
using namespace AgilentIOUtilsLib;
int main(int argc, char* argv[])
{
CoInitialize(0);
try
{
int i; /* Used for loop counter */
HRESULT hr;
/* smart pointer to iomanager interface */
IIOManagerPtr ioMgr(__uuidof(AgtIOManager) );
IIOPtr ioPtr; /* smart pointer to IO interface (This could be IIOGPIBPtr instead)*/
ioPtr = ioMgr->ConnectToInstrument ("GPIB::3"
; /* set GPIB address to 3 */
_variant_t strVar; /* VARIANT returned from instr queries */
int samples=10; /* Number of measurements to take */
_bstr_t freq; /* Frequency string */
hr = ioPtr->Output("*RST"
;
hr = ioPtr->Output("*CLS"
;
hr = ioPtr->Output("*SRE 0"
; /* Clear service request enable register */
hr = ioPtr->Output("*ESE 0"
; /* Clear event status enable register */
hr = ioPtr->Output(":STAT
RES"
; /* Preset enable registers and transition
filters for operation and questionable
status structures */
hr = ioPtr->Output(":FUNC 'FREQ 3'"
; /* Make a frequency measurement */
hr = ioPtr->Output(":FREQ:ARM:STAR:SOUR IMM"
; /* These 2 lines enable the */
hr = ioPtr->Output(":FREQ:ARM:STOP:SOUR TIM"
; /* TIME arming mode*/
hr = ioPtr->Output(":FREQ:ARM:STOP:TIM .1"
; /* 0.1 second gate time */
hr = ioPtr->Output(":INIT:CONT ON"
; /* take continuous measurements */
printf("Measuring Frequency.../n/n"
;
for (i = 0; i < samples; i++)
{
strVar = ioPtr->Query (":FETCH:FREQUENCY?"
;
printf("Freq %i: %S",i+1,strVar.bstrVal);
}
// printf("/nPress a key to continue/n"
;
getch();
}
catch (_com_error &e)
{
_bstr_t dsp = e.Description();
_bstr_t emsg = e.ErrorMessage();
printf ("COM Exception occurred during processing!/nDescription::%s/nMessage::%s/n",
(char *) dsp, (char *) emsg);
}
CoUninitialize();
return
其中ConnectToInstrument(widestring
levariant)和output(widestring
levariant)中的是olevariant类型,如果在Delphi中应怎样实现啊