ilvjyw Posted March 11, 2016 Share Posted March 11, 2016 The following is the API document: IOTCAPIs.dll int IOTC_Lan_Search2_Ex ( struct st_LanSearchInfo2 * psLanSearchInfo2, int nArrayLen, int nWaitTimeMs, int nSendIntervalMs ) ------------------------------------------------------------------------------------------------------- st_LanSearchInfo2 Struct Reference #include Data Fields char UID [21] The UID of discovered device. char IP [16] The IP address of discovered device. unsigned short port The port number of discovered device used for IOTC session connection. char DeviceName [132] The Name of discovered device. char Reserved Reserved, no use. ---------------------------------------------------------- How to use au3 dllcall ! help me! Link to comment Share on other sites More sharing options...
JohnOne Posted March 11, 2016 Share Posted March 11, 2016 $struct = DllStructCreate("char UID [21]; char IP [16]; ushort port ; char DeviceName [132]; char Reserved") DllCall("IOTCAPIs.dll", "int", "IOTC_Lan_Search2_Ex", "struct*", DllStructGetPtr($struct), "int", $ArrayLen, "int", $nWaitTimeMs, "int", $nSendIntervalMs) Maybe ilvjyw 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ilvjyw Posted March 12, 2016 Author Share Posted March 12, 2016 @JohnOne Thanks! st_LanSearchInfo2 maybe an Array Your code seems to be wrong.. How to Create an Struct array? I don't understand... Link to comment Share on other sites More sharing options...
JohnOne Posted March 12, 2016 Share Posted March 12, 2016 (edited) You cannot pass an autoit array to that dll, it wont know what it is. Show the call you made, Edited March 12, 2016 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ilvjyw Posted March 12, 2016 Author Share Posted March 12, 2016 api : int IOTC_Lan_Search2_Ex ( struct st_LanSearchInfo2 * psLanSearchInfo2, int nArrayLen, int nWaitTimeMs, int nSendIntervalMs ) Used for searching devices in LAN. When client and devices are in LAN, client can search devices and their name by calling this function. Parameters psLanSearchInfo2 [in] The array of struct st_LanSearchInfo2 store the search result and Device name. nArrayLen [in] The size of psLanSearchInfo2 array nWaitTimeMs [in] Period (or timeout) of searching LAN. (milliseconds) nSendIntervalMs [in] Interval of sending broadcast for searching device in LAN. (milliseconds) Link to comment Share on other sites More sharing options...
ilvjyw Posted March 12, 2016 Author Share Posted March 12, 2016 @JohnOne C code: #include "stdafx.h" #define MAX_ARRAY_SIZE 50 int _tmain(int argc, _TCHAR* argv[]) { IOTC_Initialize2(0); st_LanSearchInfo2 psLanSearchInfo[MAX_ARRAY_SIZE]; memset(psLanSearchInfo, 0, sizeof(st_LanSearchInfo2)*MAX_ARRAY_SIZE); int count = 0; IOTC_Lan_Search2(psLanSearchInfo, MAX_ARRAY_SIZE, 5000); for (int i = 0; i < MAX_ARRAY_SIZE; i++) { if (psLanSearchInfo.UID[0]) ++count; } printf("Total Tutk ID count:%d\n", count); for (int i = 0; i < MAX_ARRAY_SIZE; i++) { if (psLanSearchInfo.UID[0]) { printf("UID:%s IP:%s Port:%d DeviceName:%s\n", psLanSearchInfo.UID, psLanSearchInfo.IP, \ psLanSearchInfo.port, psLanSearchInfo.DeviceName); }else{ break; } } return 0; } Link to comment Share on other sites More sharing options...
JohnOne Posted March 12, 2016 Share Posted March 12, 2016 I have thought about it, but do not know how to further assist, I'm sure someone else will be better able to. Be patient, weekends are pretty quiet here. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ilvjyw Posted March 12, 2016 Author Share Posted March 12, 2016 JohnOne thank you! Link to comment Share on other sites More sharing options...
LarsJ Posted March 13, 2016 Share Posted March 13, 2016 You can test with code like this: The size of the structure in post 1 seems to be 172 bytes. You can create an array with room for 50 structures in this way: ; Structure definition $MAX_ARRAY_SIZE = 50 ;$tag_LanSearchInfo2 = "char UID[21];char IP[16];ushort port;char DeviceName[132];char Reserved" ; Structure, 174 bytes $tag_LanSearchInfo2 = "align 1;char UID[21];char IP[16];ushort port;char DeviceName[132];char Reserved" ; Structure, 172 bytes $st_LanSearchInfo2 = DllStructCreate( $tag_LanSearchInfo2 ) ; Create structure $size_LanSearchInfo2 = DllStructGetSize( $st_LanSearchInfo2 ) ; Size of structure ConsoleWrite( "$size_LanSearchInfo2 = " & $size_LanSearchInfo2 & @CRLF ) $array_LanSearchInfo2 = DllStructCreate( "byte[" & $size_LanSearchInfo2 * $MAX_ARRAY_SIZE & "]" ) ; Array of structures You have to test the code to see if you need alignment or not. Now you can call the function like this: ; Function call $nWaitTimeMs = 5000 $nSendIntervalMs = 0 ; ???? DllCall( "IOTCAPIs.dll", "int", "IOTC_Lan_Search2_Ex", "struct*", $array_LanSearchInfo2, "int", $MAX_ARRAY_SIZE, "int", $nWaitTimeMs, "int", $nSendIntervalMs ) ;DllCall( "IOTCAPIs.dll", "int:cdecl", "IOTC_Lan_Search2_Ex", "struct*", $array_LanSearchInfo2, "int", $MAX_ARRAY_SIZE, "int", $nWaitTimeMs, "int", $nSendIntervalMs ) You have to test the code to see if you need the "cdecl" calling convention. ; Get count $count = 0 $pointer = DllStructGetPtr( $array_LanSearchInfo2 ) For $i = 0 To $MAX_ARRAY_SIZE - 1 $st_LanSearchInfo2 = DllStructCreate( $tag_LanSearchInfo2, $pointer ) If DllStructGetData( $st_LanSearchInfo2, "UID" ) Then $count += 1 $pointer += $size_LanSearchInfo2 Next ConsoleWrite( "$count = " & $count & @CRLF ) JohnOne and ilvjyw 2 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
ilvjyw Posted March 18, 2016 Author Share Posted March 18, 2016 @LarsJ Thank you for your help! Link to comment Share on other sites More sharing options...
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