LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a labview dll from visual c++ 2005/2008

Hi

 

I am looking into making some DLL files in LabVIEW 8.5 that can be called from other programming environments. Initially I want to call a simple DLL that multiplies two numbers and gives the result. I have made the VI / DLL with the corresponding in- and outputs and compiled it. So now I have got my DLL, SharedLib.h, SharedLib.lib etc.

Can anyone now show me how I can call this DLL from e.g. Visual C++ 2005/2008?

 

Best regards

Simon

LabVIEW 8.6 / 2009 / 2010
Vision Development Module 8.6 / 2009 / 2010
VBAI 3.6 / 2010
0 Kudos
Message 1 of 6
(3,416 Views)
Will this be using .NET? If so, you may want to take a look at this article: How Do I Use a LabVIEW DLL in Microsoft Visual Studio.NET?
Message 2 of 6
(3,405 Views)

Hi Smercurio

 

Yea it's something like that I am looking for, especially the example from MSDN with a C++ example.

To be honest, I don't normally program in C++, I just have to do some pretest on some DLLs before I send it on to some other people:-)

 

So, the C++ example I found to be the closest one to what I need, is

 

using namespace System::Runtime::InteropServices;

typedef void* HWND;
[DllImport("user32", CharSet=CharSet::Auto)]
extern "C" IntPtr MessageBox(HWND hWnd,
String* pText,
String* pCaption,
unsigned int uType);
void main(void) {
String* pText = L"Hello World!";
String* pCaption = L"Platform Invoke Sample";
MessageBox(0, pText, pCaption, 0);
}

 To call my DLL, I have got the following parameters

       double mycalculator(double myinput1, double myinput2)

which returns a result.

 

To test this I have installed Microsoft Visual C++ 2008 Express Edition.

Now I just need some clever people to help me with a little test example 🙂

 

Best regards

Simon

LabVIEW 8.6 / 2009 / 2010
Vision Development Module 8.6 / 2009 / 2010
VBAI 3.6 / 2010
0 Kudos
Message 3 of 6
(3,378 Views)

Here's an older tutorial but it still applies for newer versions of LV and Visual Studio. Should do the trick.

 

-snow

CTA, CLA, MTFBWY
0 Kudos
Message 4 of 6
(3,345 Views)
That tutorial does not apply to .NET. .NET calls DLLs as unmanaged code. Visual C++ 6 had no concept of managed/unmanaged calls.
0 Kudos
Message 5 of 6
(3,318 Views)

Are you using Managed C++? You didn't specify that in your original post. If you're using Unmanaged C++ then the tutorial is still relevant.

 

Anyway, if you're using Managed you use PInvoke instead of natively calling the dll.

 

-snow

CTA, CLA, MTFBWY
0 Kudos
Message 6 of 6
(3,304 Views)