Represents a late-bound COM object.
Examples
Automating CDOSYS:
scope message = new DispatchObject("CDO.Message");
message.set("Subject", "Hello, World!");
message.set("TextBody", "Just saying hello.");
message.set("From", "me@home.com"); message.set("To", "world@large.com");
scope config = message.get("Configuration");
config.set("Fields", "http://schemas.microsoft.com/cdo/configuration/sendusing", 2); config.set("Fields", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
config.set("Fields", "http://schemas.microsoft.com/cdo/configuration/smtpserver", "mail.remote.com"); config.set("Fields", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1); config.set("Fields", "http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); config.set("Fields", "http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
scope fields = config.get("Fields");
fields.call("Update");
message.call("Send");
Automating Microsoft Office Excel:
void main() {
scope excel = new DispatchObject("Excel.Application");
excel.set("Visible", true);
scope workbooks = excel.get("Workbooks");
scope workbook = workbooks.call("Add");
scope worksheet = excel.get("Worksheets", 1);
worksheet.set("Cells", 5, 3, "data");
}
Automating Internet Explorer:
abstract final class InternetExplorer {
static class Application : DispatchObject {
this() {
super("InternetExplorer.Application");
}
void visible(bool value) {
set("Visible", value);
}
bool visible() {
return get!(bool)("Visible");
}
void navigate(string url) {
call("Navigate", url);
}
}
}
void main() {
scope ie = new InternetExplorer.Application;
ie.visible = true;
ie.navigate("www.google.com");
}
this(Guid clsid, ExecutionContext context = cast(ExecutionContext)1u | cast(ExecutionContext)4u);
this(Guid clsid, string server, ExecutionContext context = cast(ExecutionContext)1u | cast(ExecutionContext)16u);
this(string progId, ExecutionContext context = cast(ExecutionContext)1u | cast(ExecutionContext)4u);
this(string progId, string server, ExecutionContext context = cast(ExecutionContext)1u | cast(ExecutionContext)16u);
this(IDispatch target);
this(VARIANT target);
final void release();
R call(R = DispatchObject)(string name,...);
R get(R = DispatchObject)(string name,...);
void set(char[] name,...);
void setRef(char[] name,...);
final IDispatch target();
final VARIANT result();