LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to poke with response using DDE

I am trying to communicate with a windows application using the antiquated DDE interface, I know this interface has been overtaken by ActiveX but the application i am talking to (ZEMAX – optical modelling software) doesn't implement it.

I have managed to post requests to the application and receive responses, all successfully. However one of the functions that I need to implement requires passing a pointer to a data structure to the application, I have the c code equivalent but no idea how to implement it. I have been using the supplied dde.llb but can find no documentation for it.

This is the 'c' equivalent of the code i need to implement, can anyone help me with this???:

int PostArrayTraceMessage(char *szBuffer, DDERAYDATA *RD)
{
ATOM aItem;
HGLOBAL hPokeData;
DDEPOKE * lpPokeData;
long numbytes;
int numrays;


if (RD[0].opd > 4)
{
/* NSC Rays */
numrays = (int)RD[0].opd - 5;
}
else
{
/* sequential rays */
numrays = RD[0].error;
}

/* point to where the data is */
rdpGRD = RD;
ngNumRays = numrays;

numbytes = (1+numrays)*sizeof(DDERAYDATA);
hPokeData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (LONG) sizeof(DDEPOKE) + numbytes);
lpPokeData = (DDEPOKE *) GlobalLock(hPokeData);
lpPokeData->fRelease = TRUE;
lpPokeData->cfFormat = CF_TEXT;
memcpy(lpPokeData->Value, RD, numbytes);

/* clear the buffers */
szGlobalBuffer[0] = '\0';
szBuffer[0] = '\0';

aItem = GlobalAddAtom("RayArrayData");
GlobalUnlock(hPokeData);
if (!PostMessage(hwndServer, WM_DDE_POKE, (WPARAM) hwndClient, PackDDElParam(WM_DDE_POKE, (UINT) hPokeData, aItem)))
{
MessageBox (hwndClient, "Cannot communicate with ZEMAX!", "Hello?", MB_ICONEXCLAMATION | MB_OK);
GlobalDeleteAtom(aItem);
GlobalFree(hPokeData);
return -1;
}
GlobalDeleteAtom(aItem);

WaitForData(hwndClient);
strcpy(szBuffer, szGlobalBuffer);

/* clear the pointer */
rdpGRD = NULL;

if (GotData) return 0;
else return -1;
}


Thanks for your help.

Regards,

Tom
0 Kudos
Message 1 of 6
(3,909 Views)
I'm not sure exactly what your code snippet is attempting, but if you are dependent on LabVIEW determining the pointer you probably are out of luck. There has been an ongoing thread in the last week regrading passing pointers to ActiveX and .NET so I won't belabor it too much other than to say that LabVIEW is running in its own memory space and isn't "aware" of what is in other code space. For a much better discussion look over the last few days (last week in particular) for the .NET/ActiveX discussions.

There may be solutions, there were a number of posts to that thread that I haven't looked at, like writing dll's that encapsulate the "offending code" and provide sort of a translation medium.

Good luck

P.M.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 6
(3,898 Views)
So as not to be just negative, here are a couple of threads from a little longer ago,

http://forums.ni.com/ni/board/message?board.id=170&message.id=110479&requireLogin=False

http://forums.ni.com/ni/board/message?board.id=170&message.id=16634&requireLogin=False

note: the second one had a response from Greg M. one of the original developers of LabVIEW.


P.M.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 3 of 6
(3,893 Views)
Im still none the wiser.

Perhaps I can clarify the problem. The function I want to replicate passes a pointer to a large data structure to the application through a 'DDE poke' command. The DDE application then modifies the data, then it is read back in the control application.

I have been using the LabVIEW provided DDE VIs, but the supplied poke command only takes a string input and does not return anything. I assume that I must get a pointer to the structure and then cast that to a string but I am not sure as I don't know how the VIs are implemented.

Alternatively I guess the implemented VIs are tailored to just passing strings. Is the original developer of these VIs still about??

Thanks for the help,

Tom
0 Kudos
Message 4 of 6
(3,869 Views)
Attached are the 'c' functions in full that I am trying to replicate...
0 Kudos
Message 5 of 6
(3,867 Views)
Hello, Tom:
 
 I wonder if you are still active in this forum. Anyway, I want to use this DDE protocol as well to use a LabView routine from ZEMAX. I would like to know if you were able to work out your problem, and if you could share some of your experiences, solutions....
0 Kudos
Message 6 of 6
(3,508 Views)