Board index » delphi » DDE patch for ExecuteMacro in Delphi 2.0

DDE patch for ExecuteMacro in Delphi 2.0

I don't claim to be a DDE guru, but has anyone else noticed that the
TDdeClientConv.ExecuteMacro method executes once then seems to lock up the
session?  The best I can determine is that a wait-state flag is set and never
gets cleared when the server sends a XTYP_XACT_COMPLETE callback.  For anyone
who is interested, this is the modified code that I am using to fix the
problem in DDEMAN.PAS:

{ Modified to set the user handle for the transaction.  The DdeMsgCallBack  }
{ function will not reset FWaitStat without this handle, effectively        }
{ disabling your connection after the first macro execution.  CIC  03/10/97 }
function TDdeClientConv.ExecuteMacro(Cmd: PChar; waitFlg: Boolean): Boolean;
var
  hszCmd: HDDEData;
  hdata: HDDEData;
  ddeRslt: LongInt;
  bSetHandle: Boolean;
begin
  Result := False;
  if (FConv = 0) or FWaitStat then Exit;
  hszCmd := DdeCreateDataHandle(ddeMgr.DdeInstId, Cmd, StrLen(Cmd) + 1,
    0, 0, FDdeFmt, 0);
  if hszCmd = 0 then Exit;
  if waitFlg = True then FWaitStat := True;
  hdata := DdeClientTransaction(Pointer(hszCmd), -1, FConv, 0, FDdeFmt,
     XTYP_EXECUTE, TIMEOUT_ASYNC, @ddeRslt);
  bSetHandle := DdeSetUserHandle(FConv, ddeRslt, DWord(Self));
  if (hdata = 0) or (bSetHandle = False) then FWaitStat := False
  else Result := True;
end;

--
Chad Crawley
c...@wordtech.com

 

Re:DDE patch for ExecuteMacro in Delphi 2.0


Quote
sn...@kcnet.com (Chad Crawley) wrote:
>I don't claim to be a DDE guru, but has anyone else noticed that the
>TDdeClientConv.ExecuteMacro method executes once then seems to lock up the
>session?

Strange... I have used ExecuteMacro plenty with both Delphi 1.02 and
2.01 without ever encountering what you describe. What version(s) of
Delphi are you using?

Share and Enjoy!

+--------------------from usenet----------------------+
|  Anders Bo Melander    | Phone: (+45) 31 87 91 26   |
|  Finsensvej 79, 2. tv. | mailto:a...@biocat.ruc.dk  |
|  DK-2000 Frederiksberg | work: a...@lrsoftware.dk    |
|  Denmark               | flameto:bi...@microsoft.com|
+------------------------+----------------------------+
| http://ftp.frontier.dk/public/Delphi2/tbedit01.html |
+-----------------------------------------------------+

Other Threads