Overclockers Australia Forums

OCAU News - Wiki - QuickLinks - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Software Topics > Programming & Software Development

Notices


Sign up for a free OCAU account and this ad will go away!
Search our forums with Google:
Reply
 
Thread Tools
Old 9th July 2012, 12:12 PM   #16
andyroo54 Thread Starter
Member
 
andyroo54's Avatar
 
Join Date: Feb 2010
Location: Xanthia
Posts: 2,641
Default

Quote:
Originally Posted by kreegor View Post
Are all the computers connected via DNS or DHCP? If so I think I saw some options in the network interface list that had DNS and DHCP values so it may be possible to get it from those. I'll have a look and get back to you again.

Also, I'm sure its possible to filter by range. I'll have a look at that too while I'm at it. This is good learning for me too. I've never done this before

EDIT: Or what PabloEscobar suggested above
I think if it was filtered by those ranges, then 99% of the time it would work.

Like Pablo suggested we do lablel them, but over time they can come off, some of the older ones don't have them, and the users have been trained over time to quote the IP address. If I asked them for a computer name they would be confused. Then they'd have to try to find it. If I can say, "Click the icon that looks like a house ( If I use a house icon ((Ip ADDRESS get it?))for example) then it would be easier. Plus for remote people (with tablets) they can't see the labels because they are behind the covers..

I guessed there would probably be nicer already exisiting programs, but yeah I was just more keen to try to build one to help learn it.

Last edited by andyroo54; 9th July 2012 at 12:17 PM.
andyroo54 is offline   Reply With Quote

Join OCAU to remove this ad!
Old 9th July 2012, 12:19 PM   #17
zach
Member
 
zach's Avatar
 
Join Date: May 2009
Location: chermside.bris.qld.au:80
Posts: 2,601
Default

Code:
Dim strHostName As String
strHostName = System.Net.Dns.GetHostName()
would be easier - a pc only has 1 hostname, then do nslookup or whatever on your end.

EDIT:
Whoops I should probably learn to read haha, carry on.

Last edited by zach; 9th July 2012 at 12:27 PM.
zach is online now   Reply With Quote
Old 9th July 2012, 12:24 PM   #18
andyroo54 Thread Starter
Member
 
andyroo54's Avatar
 
Join Date: Feb 2010
Location: Xanthia
Posts: 2,641
Default

Quote:
Originally Posted by zach View Post
Code:
Dim strHostName As String
strHostName = System.Net.Dns.GetHostName()
would be easier - a pc only has 1 hostname, then do nslookup or whatever on your end.
Thanks for that I'd like to have both, because preferably I'd like them to read out numbers than letters, which can be misinterpreted more easily. But yes that's why I've got a button to try to display PC name too

Edit I've added this to show machine name:

Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox2.Text = (Environment.MachineName)

    End Sub
That seems to work. So in between Pablos code and this very simple one, the program does what I want, except for the problem whereby it is display the wrong IP. But it's getting there

Last edited by andyroo54; 9th July 2012 at 12:56 PM.
andyroo54 is offline   Reply With Quote
Old 9th July 2012, 1:09 PM   #19
kreegor
Member
 
kreegor's Avatar
 
Join Date: Apr 2007
Location: Adelaide
Posts: 3,491
Default

Quote:
Originally Posted by andyroo54 View Post
Thanks for that I'd like to have both, because preferably I'd like them to read out numbers than letters, which can be misinterpreted more easily. But yes that's why I've got a button to try to display PC name too

Edit I've added this to show machine name:

Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox2.Text = (Environment.MachineName)

    End Sub
That seems to work. So in between Pablos code and this very simple one, the program does what I want, except for the problem whereby it is display the wrong IP. But it's getting there
Modify your textbox to be multiline and have scrollbars and add my code. That will give you a list of network adapters and their ip address.
kreegor is online now   Reply With Quote
Old 9th July 2012, 1:29 PM   #20
andyroo54 Thread Starter
Member
 
andyroo54's Avatar
 
Join Date: Feb 2010
Location: Xanthia
Posts: 2,641
Default

Quote:
Originally Posted by kreegor View Post
Modify your textbox to be multiline and have scrollbars and add my code. That will give you a list of network adapters and their ip address.
I'm... not really sure how to do this.. haha, but I've tried it on a few work PC and it works fine.. only doesn't work if you have virtual machines because for some reason virtuals take precedence and display their address first, even if they aren't first in the list of adapters.

But 99% of our users don't have virtuals, and if they do, they can click show PC name.. This is awesome thanks everyone for their help. I will credit you in the code! I'm going to make an installer and I'll upload it when it's done.

Thanks,
andyroo54 is offline   Reply With Quote
Old 9th July 2012, 2:47 PM   #21
kreegor
Member
 
kreegor's Avatar
 
Join Date: Apr 2007
Location: Adelaide
Posts: 3,491
Default

Quote:
Originally Posted by andyroo54 View Post
I'm... not really sure how to do this.. haha, but I've tried it on a few work PC and it works fine.. only doesn't work if you have virtual machines because for some reason virtuals take precedence and display their address first, even if they aren't first in the list of adapters.

But 99% of our users don't have virtuals, and if they do, they can click show PC name.. This is awesome thanks everyone for their help. I will credit you in the code! I'm going to make an installer and I'll upload it when it's done.

Thanks,
Ok. Easiest way to do it is to select the textbox in the controller and in the properties window, change the multiline and scrollbar properties.


Click to view full size!


If you can't find the properties window click on the textbox in the designer and press F4.
kreegor is online now   Reply With Quote
Old 9th July 2012, 3:20 PM   #22
andyroo54 Thread Starter
Member
 
andyroo54's Avatar
 
Join Date: Feb 2010
Location: Xanthia
Posts: 2,641
Default

Quote:
Originally Posted by kreegor View Post
Ok. Easiest way to do it is to select the textbox in the controller and in the properties window, change the multiline and scrollbar properties.

pix

If you can't find the properties window click on the textbox in the designer and press F4.
I might have a look at that for version 1.1

If you want to you can download it here:

http://sourceforge.net/projects/whatisyourip/
andyroo54 is offline   Reply With Quote
Old 9th July 2012, 3:29 PM   #23
kreegor
Member
 
kreegor's Avatar
 
Join Date: Apr 2007
Location: Adelaide
Posts: 3,491
Default

haha! ASCII dinosaur! Nice touch.
kreegor is online now   Reply With Quote
Old 9th July 2012, 4:14 PM   #24
andyroo54 Thread Starter
Member
 
andyroo54's Avatar
 
Join Date: Feb 2010
Location: Xanthia
Posts: 2,641
Default

Quote:
Originally Posted by kreegor View Post
haha! ASCII dinosaur! Nice touch.
Haha didn't think anyone would ever see that.. I put yours and Pablo's usernames into the form code as well.

Code:
'Compiled by andyroo54, with great input from OCAU members: Kreegor andPabloEscobar.
andyroo54 is offline   Reply With Quote
Old 9th July 2012, 4:34 PM   #25
gcflora
Member
 
gcflora's Avatar
 
Join Date: Jun 2012
Posts: 592
Default

Where's the git repository

Edit: Actually, it would be nice not to have to install to look at the source code...
gcflora is offline   Reply With Quote
Old 9th July 2012, 4:57 PM   #26
andyroo54 Thread Starter
Member
 
andyroo54's Avatar
 
Join Date: Feb 2010
Location: Xanthia
Posts: 2,641
Default

Quote:
Originally Posted by gcflora View Post
Where's the git repository

Edit: Actually, it would be nice not to have to install to look at the source code...
Not sure what git repositry? I wasn't sure how to post the code on sourceforge.. I mainly put it there as a good reliable download source.

But here is the form code:

Code:
Public Class Form1

    Public Function GetLocalIP() As String
        Dim _IP As String = Nothing

        ' Resolves a host name or IP address to an IPHostEntry instance.
        ' IPHostEntry - Provides a container class for Internet host address information. 
        Dim _IPHostEntry As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName())

        ' IPAddress class contains the address of a computer on an IP network. 
        For Each _IPAddress As System.Net.IPAddress In _IPHostEntry.AddressList
            ' InterNetwork indicates that an IP version 4 address is expected 
            ' when a Socket connects to an endpoint
            If _IPAddress.AddressFamily.ToString() = "InterNetwork" Then
                _IP = _IPAddress.ToString()
            End If
        Next _IPAddress
        Return _IP
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = GetLocalIP()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox2.Text = (Environment.MachineName)

    End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

    End Sub

    Private Sub Label3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
End Class
'Compiled by andyroo54, with great input from OCAU members: Kreegor andPabloEscobar.
andyroo54 is offline   Reply With Quote
Old 11th July 2012, 9:07 PM   #27
andyroo54 Thread Starter
Member
 
andyroo54's Avatar
 
Join Date: Feb 2010
Location: Xanthia
Posts: 2,641
Default

Holy crap this things been downloaded a lot?

http://sourceforge.net/projects/what...stats/timeline

46 times with Bangladesh being the top location? Maybe they think it's some kind of hacking tool? Like to find out people's IP addresses? Well technically that's what it's for but you know what I mean.
andyroo54 is offline   Reply With Quote
Old 12th July 2012, 8:16 AM   #28
gcflora
Member
 
gcflora's Avatar
 
Join Date: Jun 2012
Posts: 592
Default

Quote:
Originally Posted by andyroo54 View Post
Holy crap this things been downloaded a lot?

http://sourceforge.net/projects/what...stats/timeline

46 times with Bangladesh being the top location? Maybe they think it's some kind of hacking tool? Like to find out people's IP addresses? Well technically that's what it's for but you know what I mean.
My two projects on sourceforge get mostly downloaded from China (they are scientific apps, one with a very narrow range of applicability - or so I thought).
gcflora is offline   Reply With Quote
Old 24th July 2012, 5:44 PM   #29
Foliage
Member
 
Foliage's Avatar
 
Join Date: Jan 2002
Location: Sleepwithyourdadelaide
Posts: 23,932
Default

I wrote this in 5 minutes for luls

The exe
https://dl.dropbox.com/u/1428435/Wha...IpCompiled.zip

The .net C# source code and project
https://dl.dropbox.com/u/1428435/Wha...alIpSource.zip

Code:
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                output.Text = "";
                IPHostEntry host;
                string localIP = "?";
                host = Dns.GetHostEntry(Dns.GetHostName());
                foreach (IPAddress ip in host.AddressList)
                {
                    output.Text += ip.ToString() + "\n";
                }
            }
            catch (Exception ex)
            {
                output.Text = "Shit guys, something went wrong!" + ex.Message;
            }
        }


to convert between C# and VB.net code use this website
http://www.developerfusion.com/tools.../csharp-to-vb/
__________________
You know, if you watch Titanic backwards, it's actually a heart warming tale of a ship that jumps out of the water and saves lots of drowning people.

Last edited by Foliage; 24th July 2012 at 5:46 PM.
Foliage is offline   Reply With Quote
Old 8th August 2012, 10:37 PM   #30
Foliage
Member
 
Foliage's Avatar
 
Join Date: Jan 2002
Location: Sleepwithyourdadelaide
Posts: 23,932
Default

sure am glad I bothered helping
__________________
You know, if you watch Titanic backwards, it's actually a heart warming tale of a ship that jumps out of the water and saves lots of drowning people.
Foliage is offline   Reply With Quote
Reply

Bookmarks

Sign up for a free OCAU account and this ad will go away!

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time now is 9:59 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. -
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Internode!