Next Previous Up Top Contents Index

4.5 Building an Automation controller application

4.5.8 Skeleton OLE Automation controller

The following skeleton code for a simple Automation controller combines the features discussed in sections 4.5.1 to 4.5.7:

OLE-initialize();  // Initialize OLE libraries

let dispinterface = create-dispatch(class-id); // Start server

let disp-id = get-id-of-name(disp-interface, "frob"); // Look method up

let result = call-simple-method(dispinterface, disp-id, "foo", "bar"); // Call the method

Release(dispinterface); // Release the server

OLE-uninitialize(); // Shut down OLE

A controller application that fits this simple model can be made even simpler using the macro with-dispatch-interface:

with-dispatch-interface dispinterface (class-id)
  let disp-id = 
    get-id-of-name(dispinterface, "frob"); // Look method up

let result = call-simple-method(dispinterface, disp-id, "foo", "bar"); // Call the method

end with-dispatch-interface;

Furthermore, if a DISPID will only be used once, the member name can just be passed directly to get-property or call-simple-method instead with no loss of efficiency. So we could do:

with-dispatch-interface disp-interface (class-id)
  let result = call-simple-method(disp-interface, "frob", "foo",
                                  "bar");
end with-dispatch-interface;


OLE, COM, ActiveX and DBMS Reference - 31 MAR 2000

Next Previous Up Top Contents Index