Jump to content

Labview DLL Call help


ABV
 Share

Recommended Posts

Hi All

I am trying to call a very simple Dll Created in Labview, the Lv function Has one 16bit integer as an output

see LV.Jpg

I have build a 'C' style Dll, see Dll.Jpg

The function prototype for this DLL is

void LVDLL(short *Value)

And My code is

Local $Mydata
Local $Dll = -1
Local $result = -1

$Dll = DllOpen("c:\LVdll.dll")

$result = DllCall($Dll,"none","LVdlltest","short *",$Mydata)

msgbox(0,"",$result & "," & $Dll & "," & $Mydata)


DllClose($dll)

Although the returned values all look ok, I get nothing back fom the DLL, I am not sure it has been called

If I use

$result = DllCall($Dll,"none","LVdlltest","short",$Mydata)

It looks like the DLL has been called but autoIt crashes with the failure.jpg

I have attached the DLL files in the zip

Has any one got any suggestions?

Thanks

post-65771-0-51762500-1313068085_thumb.j

post-65771-0-07293600-1313068420_thumb.j

post-65771-0-03766400-1313068740_thumb.j

LVdll.zip

Link to comment
Share on other sites

If the function prototype is:

void LVDLL(short *Value)

Why do you call "LVdlltest" and not "LVDLL"?

$result = DllCall($Dll,"none","LVdlltest","short *",$Mydata)

No idea if that's it, but it might help to call the correct function.

Good question

'LVDLL' is the name of the DLL, which is a shared library (DLL)

'LVdlltest' is the function within the shared library that I want to use, (LVDLL->LVdlltest)

Link to comment
Share on other sites

I've downloaded your attachment and found that AutoIt has a problem opening the dll file.

Local $Mydata
Local $Dll = -1
Local $result = -1

$Dll = DllOpen("LVdll.dll")
ConsoleWrite("Result of DLL open: " & $Dll & @CRLF)

$result = DllCall($Dll,"none:cdecl","LVdlltest","short*",$Mydata)
ConsoleWrite("Result of DLL call: " & $result & ". Error code: " & @error & @CRLF)

DllClose($dll)

Result:

>Running:(3.3.6.1):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\Jos\Downloads\LVdll\test.au3"    
Result of DLL open: -1
Result of DLL call: 0. Error code: 1
+>15:54:45 AutoIT3.exe ended.rc:0

A moment later, when I tried to check out the dll from another language, I got an error about needing the LabVIEW Run-Time Engine. Unfortunately, I can't make a reproduction script on this computer. Can you run the script above to check if the dll is being opened correctly?

One other important detail: You missed the note about calling cdecl functions. Your prototype is:

void __cdecl LVdlltest(short *Numeric);

so you must use "none:cdecl" as return type. (Or "int:cdecl" etc.)

Link to comment
Share on other sites

I've downloaded your attachment and found that AutoIt has a problem opening the dll file.

Local $Mydata
Local $Dll = -1
Local $result = -1

$Dll = DllOpen("LVdll.dll")
ConsoleWrite("Result of DLL open: " & $Dll & @CRLF)

$result = DllCall($Dll,"none:cdecl","LVdlltest","short*",$Mydata)
ConsoleWrite("Result of DLL call: " & $result & ". Error code: " & @error & @CRLF)

DllClose($dll)

Result:

>Running:(3.3.6.1):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\Jos\Downloads\LVdll\test.au3"    
Result of DLL open: -1
Result of DLL call: 0. Error code: 1
+>15:54:45 AutoIT3.exe ended.rc:0

A moment later, when I tried to check out the dll from another language, I got an error about needing the LabVIEW Run-Time Engine. Unfortunately, I can't make a reproduction script on this computer. Can you run the script above to check if the dll is being opened correctly?

One other important detail: You missed the note about calling cdecl functions. Your prototype is:

void __cdecl LVdlltest(short *Numeric);

so you must use "none:cdecl" as return type. (Or "int:cdecl" etc.)

Hi Thanks for looking,

I have run the code you suggested with the result

>"D:\MoogProg\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\dlltest.au3"

Result of DLL open: 1

Result of DLL call: . Error code: 0

>Exit code: 0 Time: 0.747

There appears to be nothing in $result

I added the line "ConsoleWrite("Value of $Mydata: " & $Mydata & ". Error code: " & @error & @CRLF)"

With the result

>"D:\MoogProg\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\dlltest.au3"

Result of DLL open: 1

Result of DLL call: . Error code: 0

Value of $Mydata: . Error code: 0

>Exit code: 0 Time: 0.691

$MyData is also empty

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...