rodent1 Posted January 16, 2012 Share Posted January 16, 2012 (edited) Hi there dll call experts, I need to retrieve data from a server. There is a (local) C++ dll that gives access to that data, but so far I've been unable to get my autoit script to connect. Here is the API info: Harm_connect parameters: Param name Direction C type Comment hostname IN char* username IN char* password IN char* Application_Name IN char* application_key IN char* protocol IN char* fill if requesting an encrypted connection (oops, not int32, I pasted the wrong thing here) port IN int32 for use with SSL encryption protocol_version IN int32 timeout_secs IN int32 max_tries IN in32 max tries to reconnect, no max if <0 autoreconnect IN boolean server_handle OUT Serverhandle** allocated by API nbticket IN/OUT NBTicket* allocated by API or passed in with past value, to be used to then open a session and get the data I'm after My code: expandcollapse popupDim $HARMRETOK = 0 ; return value when server is ready Dim $HARMRETBUSY = -6 ; return value when server is busy Dim $IPAddress = "10.96.81.22" Dim $ServerHandle = -1 Dim $TicketPtr Dim $bHandleValid = False Dim $MaxWaitMillisec = 10000 Dim $WaitTime Dim $HarmRet = -1 Dim $structIP = ByteStructFromString ( $IPAddress ) Dim $structUser = ByteStructFromString ( "Jules" ) Dim $structPwd = ByteStructFromString ( "JulesPwd" ) Dim $structProtocol = ByteStructFromString ( "trpc" ) Dim $structEmpty = ByteStructFromString ( "" ) ; create a structure to hold the server handle $structServerHandle = DllStructCreate ( "int" ) Dim $HarmNBTicket DllCall ( "C:MPCommonharm.dll", "none", "harm_connect", _ "ptr", DllStructGetPtr ( $structIP ), _ ; hostname "ptr", DllStructGetPtr ( $structUser ), _ ; username "ptr", DllStructGetPtr ( $structPwd ), _ ; password "ptr", DllStructGetPtr ( $structEmpty ), _ ; application name "ptr", DllStructGetPtr ( $structEmpty ), _ ; application key "ptr", DllStructGetPtr ( $structProtocol ), _ ; protocol "Int", -1, _ ; port "int", -1, _ ; protocol version "int", -1, _ ; timeout seconds "int", -1, _ ; max tries for connection, <0 for no max "int", 1, _ ; auto reconnect, non-zero for auto reconnecting "HANDLE", $structServerHandle, _ "ptr", $HarmNBTicket _ ) Func ByteStructFromString ( $TheString ) Dim $struct = DllStructCreate ( "byte[" & StringLen ( $TheString ) & "]" ) DllStructSetData ( $struct, 1, StringToBinary ( $TheString ) ) Return $struct EndFunc When I look at $structServerHandle or HarmNBTicket after the call, it's empty, even if I add a delay before I check the result to give the dll enough time to generate the return data. Given the API information, are my DllCall casts correct? I have tried a bunch of possibilities, but without success so far. Thanks Edited January 16, 2012 by rodent1 Link to comment Share on other sites More sharing options...
JohnOne Posted January 16, 2012 Share Posted January 16, 2012 (edited) After application_key, you are passing a struct ($structProtocol)Should this not be an Int? (protocol IN int32 fill if requesting an encrypted connection) Edited January 16, 2012 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...
rodent1 Posted January 16, 2012 Author Share Posted January 16, 2012 oops, my mistake, I put the wrong info, protocol is a char*, not an int32. That's why I turn the protocol name string into a byte array, put it into a single member structure, and use the pointer to that structure in the api call Thanks for looking into this and noticing the discrepancy! 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