From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

WM_copydata

Hello,

 

I am trying to use SendMessage with WM_Copydata to send information between two applications. Currently, I am trying to send data between two vis which has been unsuccessful.

In the end, I have to develop a Labview application which passes data to a blackbox C++ program using windows SendMessage WM_COPYDATA.

Currently, I am able to successfully send the DWDATA, and CBDATA but it seems like the LPDATA becomes invalid on the receiving end. I am not sure if I am structuring the pointer correctly, so any help would be very much appreciated.

 

Attached are the VIs that I am currently using.

 

Thanks any help would be appreciated.

 

-Ut

Download All
Message 1 of 4
(3,617 Views)

In the WM_Send VI, I'm not sure why you allocate 1000bytes instead of allocating the correct amount for the array to which you want to pass the pointer.

 

I'm not certain this is the problem, but I'm concerned that you dispose of the pointer immediately after sending the message; that means the pointer may have been disposed of before the receiving side has a chance to retrieve the data associated with it. That could explain why the pointer would become invalid.

0 Kudos
Message 2 of 4
(3,604 Views)

Hello nathand,

 

Thank you for responding. 

 

I now dispose of the pointer data on the receiving end. It seems to have the same results. It seems that the Windows Messaging Queue library I am using does not support WM_COPYDATA.

http://zone.ni.com/devzone/cda/epd/p/id/4394

I just read the comment at the bottom stating it may not work with WM_COPYDATA and pointer data. I will search for an alternative method of receiving the data. Any suggestions would be very much appreciated. Smiley Happy

 

Thanks

-Ut

0 Kudos
Message 3 of 4
(3,596 Views)

I did this it in this way:

1. write a small helper dll in C# (see attached code snippet)

2. included the dll into LabView

3. use SendMessageString and send to WindowName (name of the window)

 

This worked for me

 

-------------------------------------------------------------------
Eugen Wiebe
Bernstein AG
CLAD - Certified LabView Associate Developer
0 Kudos
Message 4 of 4
(3,315 Views)