User manual

Table Of Contents
MAUI Oscilloscopes Remote Control and Automation Manual
Early and Late Binding
The COM standard on which Automation is built supports two kinds of “binding” between client and server:
early (static), and late (dynamic, dispatch). Static binding usually involves a type library and is used
primarily by compiled languages such as C++. In this case, function entry points are resolved at compile
time. Dynamic binding (also known as late binding) involves resolving method and property calls at run
time, as opposed to compile time.
The Automation interfaces in XStreamDSO based instruments use primarily dynamic binding. From many
programming languages (VB, VBScript, etc.) this is transparent. But when you are developing applications
in C++, which does not provide late-binding natively, the use of a “helper” class is required. This is
demonstrated below:
#include "stdafx.h"
#include "AtlBase.h" CComModule _Module;
#include "AtlCom.h"
CComPtr<IDispatch> spDso;
// dispatch ptr. to root of object model (app)
CComDispatchDriver ddDso;
int main(int argc, char* argv[])
{
printf("Hello XStream World!\n");
::CoInitialize(NULL);
HRESULT hr = spDso.CoCreateInstance(L"LeCroy.XStreamDSO");
if(SUCCEEDED(hr))
{
ddDso = spDso;
// perform an Auto-Setup (app.Autosetup)
hr = ddDso.Invoke0(L"AutoSetup");
// retrieve a Dispatch ptr. to the app.Display object
CComVariant displayPtr;
hr = ddDso.GetPropertyByName(L"Display", &displayPtr);
CComDispatchDriver ddDisplay(displayPtr.pdispVal);
// enter Dual-grid mode(app.Display.GridMode = "Dual")
hr = ddDisplay.PutPropertyByName(L"GridMode", &CComVariant("Dual"));
}
return 0;
}
2-42