sp00ky 0 Posted January 3 Share Posted January 3 Dear forum, I really appreciate this forum because I can find everything I need. But today I try for the first time the CallDLL function, without success. The software I want to connect use DLL, and the manual mentions: Quote 7.2 Function Overview public int OpenConnection(byte[] ipAdr, int Port) Parameters: byte[] ipAdr is the IP address (ipv4) of the laserDESK server, most significant byte first (e.g. 127.0.0.1 corresponds to byte[0] = 127, byte[1] = 0, byte[2] = 0, byte[3] = 1). Port is the port number of the connection. It has to be defined in the laserDESK ’Hardware Configuration’ page too. Function: The method opens a TCP/IP connection to the laserDESK server and sends the login command. This command has to be executed prior to all other commands. Return value: 1 = success, 0 = error. So I wrote this code: #include <Inet.au3> #include <Array.au3> Global $hDll = DllOpen("C:\Program Files\SCANLAB\laserDesk\Remote\SLLDRemoteControl.dll") Local $adr[4]; $adr[0] = 127; $adr[1] = 0; $adr[2] = 0; $adr[3] = 1; Local $Port = 5000 Global $return = DllCall($hDll, "int", "OpenConnection", "byte", $adr, "int", $Port) Report($return[0]) DllClose($hDll) Func Report($report) Return ConsoleWrite("Return: " & $report & @CRLF) EndFunc ;==>Report The ip is 127.0.0.1, and port 5000. While trying my code, the log returns: Quote Report($return[0]) Report($return^ ERROR For sure, you'll see my error, but I didn't Thank you for your support Link to post Share on other sites
Danp2 1,360 Posted January 3 Share Posted January 3 From the help file -- Quote If the function call fails then @error is set to non-zero. Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified when passed by reference). So you should check the value of @error before accessing the variable as an array. P.S. You may need to use a structure to represent the array for the DLLCall to work correctly. See DllStructCreate in the help file. WebDriver UDF [GH&S] Latest version Wiki FAQs Link to post Share on other sites
Danyfirex 816 Posted January 4 Share Posted January 4 Can You Share DLL documenattion? Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to post Share on other sites
sp00ky 0 Posted January 4 Author Share Posted January 4 1 hour ago, Danyfirex said: Can You Share DLL documenattion? Saludos For sure, here's the file laserDESK_RemoteControl.en.pdf Link to post Share on other sites
sp00ky 0 Posted January 4 Author Share Posted January 4 1 hour ago, Danyfirex said: Can You Share DLL documenattion? Saludos And maybe the DLL file too (if you wish to try anything) SLLDRemoteControl.dll Link to post Share on other sites
genius257 155 Posted January 4 Share Posted January 4 (edited) Hi @sp00ky. It seems at least one problem is the first parameter sent to the OpenConnection method. You provide an array to the DllCall, but this is not supported by AutoIt3. I have not tested the code below, but something like this is needed to pass an array of bytes to DllCall. (not sure if the type should be struct or struct*) Local $adr = DllStructCreate("BYTE[4]") DllStructSetData($adr, 1, 127, 1) DllStructSetData($adr, 1, 0, 2) DllStructSetData($adr, 1, 0, 3) DllStructSetData($adr, 1, 1, 4) Local $Port = 5000 Global $return = DllCall($hDll, "int", "OpenConnection", "STRUCT", $adr, "int", $Port) hope it helps Edited January 4 by genius257 My Scripts: AutoIt Package Manager, AutoItObject Pure AutoIt, libvlc, Corsair CUE SDK Github: AutoIt HTTP Server, AutoIt HTML Parser Link to post Share on other sites
sp00ky 0 Posted January 4 Author Share Posted January 4 30 minutes ago, genius257 said: Hi @sp00ky. It seems at least one problem is the first parameter sent to the OpenConnection method. You provide an array to the DllCall, but this is not supported by AutoIt3. I have not tested the code below, but something like this is needed to pass an array of bytes to DllCall. (not sure if the type should be struct or struct*) Local $adr = DllStructCreate("BYTE[4]") DllStructSetData($adr, 1, 127, 1) DllStructSetData($adr, 1, 0, 2) DllStructSetData($adr, 1, 0, 3) DllStructSetData($adr, 1, 1, 4) Local $Port = 5000 Global $return = DllCall($hDll, "int", "OpenConnection", "STRUCT", $adr, "int", $Port) hope it helps no, unfortunately, it doesn't work. If I edit the DLL, I found the function: public int OpenConnection(ref byte[] ipAdr, int Port) { if (this.once) return 0; try { this.InitializeConnection(ipAdr, Port); byte[] data = TelegramBuilder.MakeCommand(1, (object) "1990"); if (data == null) return 0; SLAnswer ca; if (this.SendAndReceive(out ca, data) != 1) ca.cmd = 0; if (ca.cmd == 1) { int retVal = this.retVal; this.GetVersion(); return retVal; } if (ca.cmd == 0 || ca.cmd == 1) return 0; this.m_transmission_error |= 2; return 0; } catch { this.th.m_go = false; return -1; } } Maybe it can help Link to post Share on other sites
sp00ky 0 Posted January 4 Author Share Posted January 4 I think I found the problem: My DLL is in .NET, and use class... I probably need to look for solutions to implement .NET in Autoit. Link to post Share on other sites
Nine 1,606 Posted January 4 Share Posted January 4 Have you tried to use "cdecl" (see help file under DllCall) ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
sp00ky 0 Posted January 4 Author Share Posted January 4 2 hours ago, Nine said: Have you tried to use "cdecl" (see help file under DllCall) ? Yes I already tried that, without success. I really think the DotNet DLL is the origin of the issue... and the error message Link to post Share on other sites
genius257 155 Posted January 4 Share Posted January 4 1 hour ago, sp00ky said: Yes I already tried that, without success. I really think the DotNet DLL is the origin of the issue... and the error message Then you might need to try some of the suggestions found in this thread. My Scripts: AutoIt Package Manager, AutoItObject Pure AutoIt, libvlc, Corsair CUE SDK Github: AutoIt HTTP Server, AutoIt HTML Parser Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now