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?
CodePudding user response:
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);