LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a wrapper to build a C++ Dll that calls a C++ .lib and Use the Dll is LabView

Hi All,
 
I need to access some functions in a C++ .lib within LabView, but has no source code for the library.  Can I build a Dll in Visual C++ that calls this library, then have LabView calls the Dll? If so, how different is building this Dll compared to building a Dll from a .cpp file?  I am new to C++, could some one suggest how to use the .lib in Visual C++ 6.0 studio to build the Dll?
 
Thanks for your help.
Bryan
0 Kudos
Message 1 of 9
(3,876 Views)
Hello Bryan,
For starters, you can most certainly call a .dll in LabVIEW that was created in C. You would simply use the Call Library Function node.
I'm having a hard time understanding what you'd like to from there. I'm not sure if I can offer you any suggestions on how to build a .dll in Visual C++ but I am more than happy to assist you with any LabVIEW programming.
Cheers,
Emilie Kopp | Applications Engineer | National Instruments
0 Kudos
Message 2 of 9
(3,850 Views)
Hi Emilie,
 
Thank you for the help. Sorry for the late reply here, got caught into a few busy projects. I do have a difficult LabView problem and hope get some help.  I need to move a pop up window by using lvuser32.llb. Are pop up windows from labview or other application such as written by C++ are the same with regular windows?  Also, is there a way to find the window names of all open windows including not only labview vi windows but also windows from other applications?  Some of my non labview applications will have their names changed dynamically during execution. I need to know their exact name to access them in a vi.  
 
Regards,
Bryan 
0 Kudos
Message 3 of 9
(3,817 Views)


@BryanL wrote:
Hi Emilie,
 
Also, is there a way to find the window names of all open windows including not only labview vi windows but also windows from other applications?  Some of my non labview applications will have their names changed dynamically during execution. I need to know their exact name to access them in a vi.  


msdn.microsoft.com: Search for EnumWindows(). This will give you all top level windows.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 9
(3,812 Views)
Hi Rolf, thanks for the info. I will try to build a vi to call that function. For a more immediate need, I can use a downloaded vi that calls SetActiveWindow function, then use its output windowshandle to find the window name with a lvwuser32.dll function. The problem is this find window name function vi requires a windows reference input, which does not take the window handle output from the SetActiveWindow vi. How do i convert the window handle into a reference number? Thanks again.
0 Kudos
Message 5 of 9
(3,806 Views)


@BryanL wrote:
Hi Rolf, thanks for the info. I will try to build a vi to call that function. For a more immediate need, I can use a downloaded vi that calls SetActiveWindow function, then use its output windowshandle to find the window name with a lvwuser32.dll function. The problem is this find window name function vi requires a windows reference input, which does not take the window handle output from the SetActiveWindow vi. How do i convert the window handle into a reference number? Thanks again.


Don't try to write a VI to call that function. That function requires a callback function pointer, something that is more or less impossible (well you can get it done but it is not worth the trouble) to create in LabVIEW. You will need an external DLL that does the enumeration and returns an array of strings to LabVIEW.

The lvwuser32.dll also just uses window handles. Look inside those VIs and you should see that those window references are typecasted into uint32 and then passed to the Call Library Node if I remember correctly. You definitely should be able to typecast the (probably uint32) you get from your other function into the window reference that that VI takes. The window reference of the lvutil library is just a nice trick to make it refnum like so that you can not inadvertly wire something else to it (and confuse/crash Windows).

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 9
(3,801 Views)
Hi Rolf, you are exactly right that the two VIs I was trying to connect used different typecasts.  So I modified one and made them the same, however, they still cannot connect. I have attached both. Please give them a try. (Both VIs were downloaded from this board with credit goes to the orignal authors)
Download All
0 Kudos
Message 7 of 9
(3,799 Views)


@BryanL wrote:
Hi Rolf, you are exactly right that the two VIs I was trying to connect used different typecasts.  So I modified one and made them the same, however, they still cannot connect. I have attached both. Please give them a try. (Both VIs were downloaded from this board with credit goes to the orignal authors)


Someone wanted to be smart and used his own window handle type at some point. I would just copy the one from Get Widnwo Handle to the clipboard and replace the ones in the other VI with them. Technically they are the same as they are both a datalog refnum. But syntactically they are different since the typedef of the datalog is different and LabVIEW refuses to connect two different datalog refnums with each other. This is actually the reason to use such refnums for things like OS handles. A LabVIEW user then can't conect unrelated items together.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 8 of 9
(3,793 Views)
Thanks Rolf, that solved the problems. You got my starsSmiley Happy
0 Kudos
Message 9 of 9
(3,784 Views)