哈,自已解决了!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComObj, AutoCAD_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
acadapp:AcadApplication;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{连接到AutoCAD}
procedure TForm1.Button1Click(Sender: TObject);
begin
acadapp:=GetActiveOleObject('AutoCAD.Application') as AcadApplication;
end;
{加密AutoCAD图形文件}
procedure TForm1.Button2Click(Sender: TObject);
var
lx:AcadSecurityParams;
begin
lx:=acadapp.GetInterfaceObject('AutoCAD.SecurityParams.16') as AcadSecurityParams;
lx.Action:=ACADSECURITYPARAMS_ENCRYPT_DATA;
lx.Algorithm:=ACADSECURITYPARAMS_ALGID_RC4;
lx.Comment:='My test';
lx.Issuer:='MTuersley';
lx.KeyLength:=40;
lx.Password:=UpperCase('abc');
lx.ProviderName:='Microsoft Base Cryptographic Provider v1.0';
lx.ProviderType:=1;
lx.TimeServer:='';
acadapp.ActiveDocument.SaveAs('c:/1.dwg',ac2004_dwg,lx);
end;
{打开加密文件}
procedure TForm1.Button3Click(Sender: TObject);
begin
acadapp.Documents.Open('c:/1.dwg',1,'abc');
end;
end.