Jump to content

about dllcall help me!


ilvjyw
 Share

Recommended Posts

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

$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

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

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

@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

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 )

 

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...