09-08-2008 07:34 AM
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
09-08-2008 10:32 AM
09-09-2008 02:16 AM
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
09-10-2008 08:40 PM
Here's an older tutorial but it still applies for newer versions of LV and Visual Studio. Should do the trick.
-snow
09-11-2008 09:15 AM
09-11-2008 10:24 AM
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