LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send data to other Windows application via WM_COPYDATA

Solved!
Go to solution

Hello,

 

I need to send data (array of integers) from my LabView application to another non LabView Windows application by using  WM_COPYDATA message.  There are several posts in the forum discussing the same issue but none of them has the full solution. 

 

As I see the main problem is not to call the SendMessage/PostMessage but to make a wrapper around this call and to ensure the data is valid when the message received in the other application. There is a example for such DLL wrapper (a DLL which will deal with sending of the message and holding the data array)  but after compiling the example DLL I was not able to see it working properly.

 

In my projects I used several times WM_COPYDATA for data exchange between non LabView Windows applications and I never had problems.

 

My question is - does somebody have a working and tested example for using WM_COPYDATA to send data from LabView to another Windows applications? I'll really appreciate any help. Thank you!

0 Kudos
Message 1 of 13
(6,247 Views)

Have you tried the example shown here:

http://www.ni.com/example/29394/en/

0 Kudos
Message 2 of 13
(6,239 Views)

Hi,

Yes, I have seen this library before, but unfortunately they have only 32 bit version where the target is LV 64 bit. If you have by change the library for 64 LabView I'll be very thankful.

 

0 Kudos
Message 3 of 13
(6,205 Views)

Hey Peter,

 

Not sure if you are limited to WM_COPYDATA or need it out of a specific reason. I am sure it will work somehow, but never used it, so I cannot give any useful hints.

 

What I have done whatsoever, is using a different approach to exchange data between programs: Memory-mapped files. Mainly, it's a mix of these Win API functions:

  • CreateFileMapping
  • OpenFileMapping
  • MapViewOfFile
  • MapViewOfFileEx
  • UnmapViewOfFile
  • FlushViewOfFile
  • CloseHandle

Works on 64-bit OSs. Make sure to use 64-bit pointers etc.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 4 of 13
(6,179 Views)

I have done it in this way:

1. create .NET DLL named LVHelper

2. insert .NET DLL in LabView and use provided Method(s)

 

See attached C# file

-------------------------------------------------------------------
Eugen Wiebe
Bernstein AG
CLAD - Certified LabView Associate Developer
Message 5 of 13
(6,172 Views)

Hi EWiebe,

 

Thanks for the file. One question - how you compile this file into DLL, what compiler you used? In Visual Studio after compilation I can't see the functions listed in the DLL.

 

I tried https://www.nuget.org/packages/UnmanagedExports but still no success. Is there some existing DLL ready to use for x64 or is there hint how to compile it correctly? Thank you.

 

0 Kudos
Message 6 of 13
(6,144 Views)

See attached Project

 

BR

EWiebe

-------------------------------------------------------------------
Eugen Wiebe
Bernstein AG
CLAD - Certified LabView Associate Developer
Message 7 of 13
(6,113 Views)

Hi EWiebe,

 

Thank you for the project.

 

In Visual Studio 2013 I compiled successfully the project by removing everything connected with OfficeOpenXml (I'm not using it and and I don't have it on my computer) for target x64. The DLL is there but I can't see the functions listed in DLL - see snapshot from LabView where the function list in Call Library Function node is grayed out. Also attached a snapshot from the Visual Studio - compilation is OK.

 

Maybe the missing OfficeOpenXml has some functionality which makes the function calls published into the DLL. 

 

In short - I can compile your project in VS 2013 and see the DLL but the functions were not exported (they are not visible in LV Call Library Function Node). Any suggestions what I'm doing wrong are really appreciated!

Download All
0 Kudos
Message 8 of 13
(6,103 Views)
Solution
Accepted by topic author peter111

You have a C# project, so it is a .NET DLL.

With the Call Library Node you can only access C/C++ DLLs

 

You need the .NET Conctructor Node:

 

need_net.jpg

 

 

 

 

need_net_2.jpg

-------------------------------------------------------------------
Eugen Wiebe
Bernstein AG
CLAD - Certified LabView Associate Developer
Message 9 of 13
(6,091 Views)

Hi EWiebe,

 

Thank you so much for the help - the key moment was that this DLL is  .NET and hence needs different way to deal with. Small details - big difference! I really appreciate your help!  

 
 
0 Kudos
Message 10 of 13
(6,072 Views)