How to: Get connected to Automation


Topic:

Get connected to Automation


Class hierarchy:

IPCsApplication


Description:

To establish a connection to Automation its necessary to add the file "Dpscad_TLB.pas" in your project uses-clause.
To get or create this file, see
how to prepare for use.
To access projects, symbols, text etc. in Automation, you need to make this call to get at variable to work from. When calling PCsApplication := coApplication.Create(); Automation will start up, if not allready started


Sourcecode:
[+] Delphi
uses DPSCAD_TLB;

var
  PCsApplication : IPCsApplication;
begin
  PCsApplication := coApplication.Create();
end;

[+] Visual Basic
Private Sub CommandButton1_Click()
  Dim PCs As IPCsApplication
  Set PCs = CreateObject("PCsELautomation.Application")
End Sub

[+] C#
Dpscad.IPCsApplication PCsApplication;

public void GetConnection()
{
  Type PCs = Type.GetTypeFromProgID("PCsELautomation.Application");
  PCsApplication = (Dpscad.IPCsApplication)Activator.CreateInstance(PCs);
}