Kyan Posted April 6, 2015 Posted April 6, 2015 I may mess up with pointers and structs a little but, how I'm not getting a proper output? I was expecting to get my lan hostname using this (yes ping to that address gives the hostname) I'm always getting "0" $uip = DllCall("wsock32.dll", "long", "inet_addr", "str", "192.168.1.4")[0] $call = DllCall("wsock32.dll", "long_ptr", "gethostbyaddr", "long_ptr", $uIP, "int", 4, "int", 2) ConsoleWrite(DllStructGetPtr($call,1)&@LF) Exit arrayDisplay ouput: Row|Col 0 [0]|0x00000000 [1]|67217600 [2]|4 [3]|2 What am I messing up here? Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
JohnOne Posted April 6, 2015 Posted April 6, 2015 For a start inet_addr returns ulong, not long. Next, you are passing an array to a param that expects a string. The list goes on, you should start by doing some error checking after your calls to dll. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Kyan Posted April 6, 2015 Author Posted April 6, 2015 being long or ulong still returns 67217600 I'm passing the [0] value of $uIP array Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
JohnOne Posted April 6, 2015 Posted April 6, 2015 Yes, I see now. in any case you should pass correct type. You might get away with it and you might not, but I doubt it when the param you are passing it to expects a string. You wont know until you check for errors. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Kyan Posted April 6, 2015 Author Posted April 6, 2015 Errors? @error is 0 and long_ptr gethostbyaddr is 0 (no WSA error for 0 https://msdn.microsoft.com/en-us/library/windows/desktop/ms738521%28v=vs.85%29.aspx) Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
JohnOne Posted April 6, 2015 Posted April 6, 2015 Would it be too much trouble for you to post all the code you are trying? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Kyan Posted April 6, 2015 Author Posted April 6, 2015 that's all the code to get the other lan computer name, I'm also trying with WMI using System.Net.Dns.GetHostEntry() but I don't know how to create an object for System class Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
JohnOne Posted April 6, 2015 Posted April 6, 2015 Still no error checking then? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Kyan Posted April 7, 2015 Author Posted April 7, 2015 This is the updated code, still outputing the 0 Local $uip = DllCall("wsock32.dll", "ulong", "inet_addr", "str", "192.168.1.4")[0] $call = DllCall("wsock32.dll", "ptr", "gethostbyaddr", "ptr", $uIP, "int", 4, "int", 2) ConsoleWrite(DllStructGetPtr($call,1)&@LF) Exit Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
JohnOne Posted April 7, 2015 Posted April 7, 2015 Still no error checking then? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Solution BrewManNH Posted April 7, 2015 Solution Posted April 7, 2015 You should look in the Inet.au3 file for the function _TCPIPToName function to see how it is done in there. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Kyan Posted April 7, 2015 Author Posted April 7, 2015 (edited) wow nice, tried on my local ip (since is the only one active now) and got @ERROR = 4, @Extended = 10093 = WSANOTINITIALISED I don't know what to do now DllCall($hDll_Ws2_32, "ptr", "gethostbyaddr", "ptr*", $vBinIP, "int", 4, "int", $iAF_INET) returned 0 (what was happening), and then called WSAGetLastError to get the error, should I call WSAStartup before running gethostbyaddr? EDIT: If WSAStartup is really necessary, I don't know how should I create this struct WSADATA, and how do I put the wsock32 versions in a byte I know that LByte is the first 4bits (right?) HByte is the last 4bits, but if the version is 2.2 how do I put it in bits? :s bits are 0 or 1 Edited April 7, 2015 by Kyan Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
BrewManNH Posted April 7, 2015 Posted April 7, 2015 If you look at the help file entry for _TCPIPToName, you'll see that you need to use TCPStartUp() before you can use the TCP functions, so I'm assuming you'd need to do that with your DLLCall as well. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Kyan Posted April 7, 2015 Author Posted April 7, 2015 Indeed, works only took 26ms to fetch the other host name Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
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