Link to home
Start Free TrialLog in
Avatar of Dazza051197
Dazza051197

asked on

DDEPoke Structure

Has anyone got any information/examples regarding the DDEPoke
facility.  As I'm sending data to a 3rd party application that wants
the data in it's own format, I can't use the DDE components that came
with Delphi, so I have to use the Win API ones.  I've managed to
receive data but I've got a problem when it comes to sending data.

I've got something like this so far, but it keeps crashing the 3rd
party application.

var
  ItemAtom : TAtom;
  hData : THandle;
  poke : ^TDDEPoke;
  gc   : TMyData;
begin
   hData:=GlobalAlloc(GHND or GMEM_DDESHARE ,
sizeof(TDDEPOKE)+sizeof(TMyData));

   poke:=GlobalLock(hData);
   if poke=NIL then
      exit;
   poke^.cfformat:=cfGrail;   { Already registered with the clipboard
}
   poke^.flags:=0;

   move(gc,poke^.value,sizeof(gc));

   GlobalUnlock(hData);
   itematom := GlobalAddAtom('CONFERENCE');
   if PostMessage(hWndGrail,wm_DDE_POKE,
Handle,MAKELPARAM(hData,itematom)) then

etc. etc.

Anyone done anything like this and can shed any light onto the matter
?

Regards
Darren
Avatar of sperling
sperling

When do you dispose the memory block?

Erik.
Avatar of Dazza051197

ASKER

Memory block disposed of when I receive a DDEAck from the other application.  But I never get that far because the other app GPF's.  If I mess around with the GMEM_xxxx options then I sometimes get the other app not to GPF but it doesnt get the actual data I'm sending, it gets some garbage.
Is this 16 or 32-bit?

Erik.

I'm writing it in 32 bit Delphi 2, but the database application I'm talking to is only 16 bit, but does work ok on Win 95 and NT.
ASKER CERTIFIED SOLUTION
Avatar of sperling
sperling

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Apologies for my late reply.  You pointed me in the right direction, the problem was with the 32 bit handle being a long and the 16 bit application I'm talking to didn't like it.  I needed to be able to make a long up from my 2 integers so 32 bit Delphi is out of the question, I've now compiled my program successfully in 16 bit Delphi (thank goodness they put that on the CD with Delphi 2).  Any one know how to get a 16 bit handle to a global memory location so I dont need 2 applications.
Hummm... A possibility would be writing the DDE part in a 16-bit DLL and then thunk down calling it from your app.

Regards,

Erik.