LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling dll Help

Solved!
Go to solution

Hi,

 

I have a question about calling dlls.  I have a dll which I can call some of the functions, but not others.  I get the "LabVIEW: An exception..." error on some of the functions.  The function prototype I can call is:

 

_ScriptSleep@4(dword param_1)

calling convention = stdcall

 

This one works, but when I try to call this function, it does not work:

 

_ALeSetSpot@4(dword param_1)

calling convention = stdcall

 

Both of these functions have an "_" infront of them.  I can't seem to figure out what I am doing wrong.

 

 

0 Kudos
Message 1 of 17
(3,847 Views)
Where's the .h file that you used to determine the function prototype? Are you sure that these functions are exported in the dll?
0 Kudos
Message 2 of 17
(3,832 Views)
I don't have the header file.  I was told by the company's application people all the function prototypes.  They said it should be no problem to interface LabVIEW with the .dll file, but when I asked them about the error all they said was they don't offically offer support for LabVIEW with their product.  The functions should be exported in the .dll because another standalone program can call the dll and issue the same commands I am trying to call.  I have tried some more functions, some work and some generate the error.  Am I calling the dll incorrectly? 
0 Kudos
Message 3 of 17
(3,825 Views)

Regrettably I cannot run the DLL calls as it relies on further DLLs (e.g. sbdconnection.DLL) that I do not have.
I cannot see any obvious problem in your code.
I can see, that the two functions you have mentioned are exported by the DLL.
LabVIEW 8.2.1 sees the functions without mangled names (e.g. ScriptSleep).

The only thing you should change: A dword is usually a U32 in LabVIEW. You have specified an I32. This should not be a problem as long as you do not pass negative numbers to the DLL.
Hope this helps, Guenter

0 Kudos
Message 4 of 17
(3,818 Views)
Thanks for the help, here are the missing dlls.  I tried changing the I32 to U32, but that did not help.  Any other ideas?
0 Kudos
Message 5 of 17
(3,813 Views)

Can you send the vpro32.DLL, please? xtautolib.DLL also requires it and I do not have any idea where to get this DLL?

Is there a chance that I can run the VI then? Or is any hardware required?

Thanks in advance, Guenter

0 Kudos
Message 6 of 17
(3,810 Views)
The names indicate that you have a C++ DLL. You should confirm this with whomever gave you the DLL. LabVIEW cannot call C++ DLLs. If you cannot get a regular C DLL from the company that gave you the DLL then you will need to write a wrapper C DLL that LabVIEW can call.
Message 7 of 17
(3,797 Views)
Although I met this statement ("LabVIEW cannot call C++ DLLs.") quite often I have to say that I have occasionally met DLLs created in C++ and as long as the functions in these DLLs use simple data types there is a good chance that they will work with LabVIEW. I have created a very small C++ DLL in Visual Studio 6 and named it "simple.DLL". The only exported function is
SIMPLE_API DWORD fnSimple(DWORD a, DWORD b)
{
    return (a+b);
}
and can be reliably called from LabVIEW as you can take from the attached VI which calls the DLL in a For Loop. (The loop is intended to check, that there are no memory issues with the stack.)

shivels' DLL calls also take simple data types. There should be a good chance to get them run.
Regards, Guenter
I attached the VI and the DLL and the rest of the Visual Studio stuff.
0 Kudos
Message 8 of 17
(3,784 Views)

Guenter Mueller wrote:
Although I met this statement ("LabVIEW cannot call C++ DLLs.") quite often I have to say that I have occasionally met DLLs created in C++ and as long as the functions in these DLLs use simple data types there is a good chance that they will work with LabVIEW.

See here: Building a DLL with Visual C++, especially Step 3. This is not new. If the DLL is compiled so that the functions names are not decorated then the DLL will work, even if it's compiled with a C++ compiler. However, LabVIEW will not be able to instantiate classes from the DLL. 

0 Kudos
Message 9 of 17
(3,775 Views)

Right you are. Thanks for referring to the link that properly points out, that "Without C++ decoration, polymorphic functions are not possible."

To my opinion, no polymorphism and no object creation needs to be considered when shivels tries to use his DLL. There should be a chance to successfully call it from LabVIEW.

Regards, Guenter

0 Kudos
Message 10 of 17
(3,769 Views)