E1M1 Posted October 31, 2011 Posted October 31, 2011 (edited) From tcp server example I found code converts Int to string $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", 2130706433) If Not @error Then $aRet = $aRet[0] But how i can convert string IP to int again? Solution: inet_addr Edited October 31, 2011 by E1M1 edited
KaFu Posted October 31, 2011 Posted October 31, 2011 (edited) MSDN is your friend , search for inet_ntoa, read documentation and look for similar functions... $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", 2130706433) If Not @error Then $aRet = $aRet[0] ConsoleWrite($aRet & @crlf) $aRet = DllCall("Ws2_32.dll", "long", "inet_addr", "str", $aRet & chr(0)) If Not @error Then $aRet = $aRet[0] ConsoleWrite($aRet & @crlf) Edit: To be correct, return is long on not int. Edited October 31, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
E1M1 Posted October 31, 2011 Author Posted October 31, 2011 thanks, I googled for it but didn't find. or actually didn't know what to look edited
trancexx Posted October 31, 2011 Posted October 31, 2011 (edited) I would go with more natural solution any time over that calls considering the language we use: $sIP = "255.255.255.255" ; Verify reversibleness ConsoleWrite(_IPToString(_StringToIP($sIP)) & @CRLF) Func _IPToString($iIP) Return Number(BinaryMid($iIP, 1, 1)) & "." & Number(BinaryMid($iIP, 2, 1)) & "." & Number(BinaryMid($iIP, 3, 1)) & "." & Number(BinaryMid($iIP, 4, 1)) EndFunc Func _StringToIP($sIP) Local $aIP = StringSplit($sIP, ".") ReDim $aIP[5] Return Dec(Hex($aIP[4], 2) & Hex($aIP[3], 2) & Hex($aIP[2], 2) & Hex($aIP[1], 2)) EndFunc ...Ssspeeeedd Edited October 31, 2011 by trancexx ♡♡♡ . eMyvnE
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