>>winexec('c:/AutoCAD15/AutoCAD.exe',1);
这种方法不好,如果已开了一个AutoCAD,则再开一个就太浪费资源了。unit
(AutoCAD 2000,支持多窗口)
ACADUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,comObj,ActiveX;
var
ACAD_HWND:HWND;
ACAD:OleVariant;
function CreateACAD:Boolean;
function ShowACAD:boolean;
implementation
function ShowACAD:boolean;
begin
if ACAD_HWND<>0 then
try
ShowWindow(ACAD_HWND, SW_RESTORE);
SetForegroundWindow(ACAD_HWND);
Result:=true;
except
Result:=false;
end
else
Result:=false;
end;
function CreateACAD:boolean;
var
Title:string;
begin
Result:=true;
try
ACAD:=GetActiveOleObject('AutoCAD.Application.15');
ACAD.Visible:=True;
Title:=ACAD.Caption;
ACAD_HWND:=Findwindow(nil,Pchar(Title));
ShowACAD;
except
try
ACAD:=CreateOleObject('AutoCAD.Application.15');
ACAD.Visible:=True;
Title:=ACAD.Caption;
ACAD_HWND:=Findwindow(nil,Pchar(Title));
ShowACAD;
except
Result:=false;
end;
end;
end;
end.