[Lazarus] Windows DDE

Ludo Brands ludo.brands at free.fr
Sat Nov 9 17:52:47 CET 2013


On 11/09/2013 03:53 PM, Daithi Haxton wrote:
> It doesn't seem to matter how I call it, it always registers a null
> string. I call it like this:
> ServiceHSz:= DdeCreateStringHandle(Inst, StringName, CP_WINANSI);
> where StringName is a const PChar and Inst is a handle returned from the
> DDEInitialize function (which I know is valid by monitoring with other
> tools). This is basically identical to the VCL from Delphi 7 and prior -
> it works find there but not with FreePascal. I'm compiling with Delphi
> mode on and get no compilation errors.
> 

afaik DDEInitialize is defined slightly different in Freepascal from Delphi.

This creates a valid DDE string handle for me:

{$mode delphi}
uses ..., windows;

var
  Res: UINT;
  g_idInst: DWORD;
  g_hszAppName: HSZ;

const DMLERR_NO_ERROR=0;

  function DDECallback(CallType, Fmt: UINT; Conv: HConv; hsz1, hsz2: HSZ;
      Data: HDDEData; Data1, Data2: DWORD): HDDEData; stdcall;
begin
//
end;

begin
  g_idInst:=0;
  Res:=DdeInitialize(@g_idInst, DdeCallback, APPCLASS_STANDARD, 0);
  if Res = DMLERR_NO_ERROR then
    g_hszAppName:= DdeCreateStringHandle(g_idInst,'DDEServer',CP_WINANSI);
end.

If g_hszAppName is 0 then call
  DdeGetLastError(g_idInst);
to see what the last error is.

Ludo




More information about the Lazarus mailing list