0

I have an application that opens the autocad app in the following way:

XlApp := GetActiveOleObject('AutoCAD.Application');

Now I want to do the same but with the ZWCAD app, how could I do it?

Marcodor
  • 4,578
  • 1
  • 20
  • 24
csb95
  • 1
  • 1
  • It is possible that ZWCAD does not register OLE type interface for accessing it as AutoCAD does. Not all applications provide OLE automation capabilities. In such case you will have to use other means for opening ZWCAD application. – SilverWarior May 03 '22 at 10:48
  • Contact the vendor of ZWCAD and ask them – David Heffernan May 03 '22 at 10:52

1 Answers1

2

GetActiveOleObject does not open an application. It returns an interface reference to a COM/OLE automation object of a running application.

If the application is not runnning, you can create/instantiate one using CreateOleObject.

Later, having a reference, you can manage the application externally, from your application. Like opening/managing some documents, do some processing and/or show it to the user.

Note, not all applications supports COM/OLE automation. You have to check official documentation or developer's guides. Usually it contains interface description, like properties and methods you can invoke. Also, Delphi offers tlibimp tool to import the available interfaces from a dll file.

After a quick check, it seems ZWCAD supports COM automation, so may try the following code:

var O: Variant;
begin
  O := CreateOleObject('ZWCAD.Application');
  try
    // Work with object
    O.Visible := True;
  finally
    O := Unassigned;
  end; 
end;

Or, if you simply want to open the ZWCAD, you can use

ShellExecute(0, 'open', 'c:\path\to\zwcad.exe', nil, nil, SW_SHOWNORMAL);
Marcodor
  • 4,578
  • 1
  • 20
  • 24
  • And witch BricsCAD? i'm trying with CreateOleObject('BricsCAD.Application') and it does not work correctly. BricsCAD supports COM automation? – csb95 May 11 '22 at 13:42