Here's a snippit from one of my Delphi Apps that
talks to AutoCAD:
connected: boolean; {global}
procedure TForm1.SendLine(Msg: String);
var
Macro: string;
Cmd: array[0..255] of Char;
begin
if ConnectToAcad then
begin
Macro := Format('[%s^13]', [Msg]);
StrPCopy(Cmd, Macro);
if not DDEClient.ExecuteMacro(Cmd, False) then
ErrorDlg('AutoCAD DDE Connection Failed');
DDEClient.CloseLink;
end;
end;
function TForm1.ConnectToAcad : Boolean;
begin
Result := connected;
if not connected then
With DdeClient do
begin
SetLink("AutoCAD.r13.dde", "system");
Result := OpenLink;
if not Result then
begin
SetLink("AutoCAD.dde", "system");
Result := OpenLink;
end;
if not Result then
ErrorDlg('Can''t establish DDE Connection with AutoCAD')
else
Connected := Result
end;
end;
--
/*******************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Expert AutoCAD Programming and Customization */
/* --------------------------------------------------- */
/* Co-Author of Maximizing AutoCAD R13 and */
/* Maximizing AutoLISP for AutoCAD R13 */
/* --------------------------------------------------- */
/* 71241.2067@compuserve.com */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*******************************************************/