Click here to Skip to main content
Licence 
First Posted 19 Aug 2004
Views 187,072
Bookmarked 76 times

LAN Messenger

By | 19 Aug 2004 | Article
A tool for communicating with the computers across the network.

Sample Image - MyLanApp.jpg

Introduction

This is a tool which is created using the Active Directory objects in VB.NET. Using this tool, we can communicate with the computers across the network.

Once the form is loaded, it will bring out all the computer names in a TreeView control. If you click on any computer name from the tree view, it will display the selected item in the right top textbox; it will show the computer name and also the IP address details below.

We have to type the message that we want to send, in the Message to Send box, and if you press the Send button, it will send the message to the selected computer.

In the same way, if we want to send messages to all the computers, if we press the Send to All button, it will send the message to all the computers; we also have a provision to ‘ping’ the selected node.

For sending messages to another computer, we have a ‘Net Send’ command; it is a DOS command. To run any executable program, we have a ‘Shell’ command.

Shell("net send " & txtcomputer.Text & " " & txtmessage.Text)

The above line is a part of the code which will send a message to a specified computer.

To Ping the another node, the following is the command:

Shell("PING " & TextBox1.Text)

In the ‘TextBox1’ we will have the IP address of the selected computer.

To get the IP Address of the computer using the tool, we have a generic function called “GetIPAddress”.

Function GetIPAddress(ByVal CompName As String) As String
Dim oAddr As System.Net.IPAddress
Dim sAddr As String
  Try
    With System.Net.Dns.GetHostByName(CompName)
oAddr = New System.Net.IPAddress(.AddressList(0).Address)
sAddr = oAddr.ToString
          End With
          GetIPAddress = sAddr
  Catch Excep As Exception
    MsgBox(Excep.Message, MsgBoxStyle.OKOnly, "Lan Messenger")
  Finally
  
  End Try
End Function

System.Net.Dns.GetHostByName

Gets the DNS information for a specified DNS host name. Only we have to pass the ‘hostname’. Returns the host information for the address specified in hostName.

System.Net.IPAddress

Provides an Internet Protocol (IP) address. The following is the code to list the computers in the network:

  Dim childEntry As DirectoryEntry
  Dim ParentEntry As New DirectoryEntry()
  Try
    ParentEntry.Path = "WinNT:"
    For Each childEntry In ParentEntry.Children
        Dim newNode As New TreeNode(childEntry.Name)
        Select Case childEntry.SchemaClassName
               Case "Domain"
               Dim ParentDomain As New TreeNode(childEntry.Name)
               TreeView1.Nodes.AddRange(New TreeNode() {ParentDomain})
               Dim SubChildEntry As DirectoryEntry
               Dim SubParentEntry As New DirectoryEntry()
               SubParentEntry.Path = "WinNT://" & childEntry.Name
               For Each SubChildEntry In SubParentEntry.Children
                   Dim newNode1 As New TreeNode(SubChildEntry.Name)
                   Select Case SubChildEntry.SchemaClassName
                          Case "Computer"
                                ParentDomain.Nodes.Add(newNode1)
                   End Select
                Next
        End Select
    Next
    Catch Excep As Exception
          MsgBox("Error While Reading Directories")
    Finally
         ParentEntry = Nothing
  End Try

System.DirectoryServices

The .NET Framework System.DirectoryServices namespace is a robust and flexible API for querying and manipulating objects in Microsoft's Active Directory.

Active Directory is Microsoft's network operating system (NOS) directory, built on top of Windows 2000 and Windows Server 2003. It enables administrators to manage enterprise-wide information efficiently from a central repository that can be globally distributed.

The two main classes within System.DirectoryServices are DirectoryEntry and DirectorySearcher. The DirectoryEntry class represents an object in the directory, and can be used to create new objects and manage existing ones.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

kennedy_franklin

Web Developer

Kuwait Kuwait

Member

I am J. Franklin Kennedy, Working as a programmer in application software developement.
 


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionSending a message PinmemberKwaku Boateng13:37 2 Jun '12  
GeneralMy vote of 5 PinmemberMuhammad Wilayat Shah9:35 21 Mar '12  
Question[My vote of 2] not great PinmemberCIDev2:27 17 Feb '12  
Questionhelp regarding the file transfer PinmemberMenon Santosh18:41 13 Feb '12  
GeneralMy vote of 5 PinmemberMojtaba Rezaeian15:04 3 Dec '11  
Questionat kennedsy_franklin PinmemberMonib zia3:16 9 Oct '11  
QuestionWhere can i do the editing of this software from?? Pinmemberdiasroyal5:20 8 Jul '11  
GeneralMy vote of 4 Pinmemberdiasroyal4:01 8 Jul '11  
QuestionNot working Pinmemberpankaj112522:28 6 Jul '11  
GeneralMy vote of 1 PinmemberArpan Kar23:06 24 Apr '11  
Questionmessage is not being sent PinmemberRAHUL238522:46 30 Dec '10  
AnswerRe: message is not being sent Pinmemberelpaez8:49 25 Nov '11  
Generalmessenger PinmemberRamani Nidhi19:54 18 Apr '09  
GeneralRe: messenger PinmemberIshanLakhia21:48 26 Apr '09  
GeneralRe: messenger Pinmemberdiasroyal4:13 8 Jul '11  
Generalhelp me to operate a lan messenger Pinmembervahid1460720:44 12 Nov '08  
Generallan messenger Pinmemberynaungsoe4:03 10 Oct '08  
Generallan messnger Pinmemberahmad_jsr198322:47 15 Aug '08  
dear sir
pls give me idea of how to devlope a lan messanger in vb.net .
Generalthanx...... PinmemberFares Amr20:09 23 Jul '08  
Generalfor create lan messanger Pinmembermansuri sahil6:12 11 Jul '08  
GeneralChat Application PinmemberUrsrathi2:54 8 Jul '08  
GeneralRe: Chat Application Pinmemberdiasroyal4:18 8 Jul '11  
QuestionThanx Sir Pinmemberrajesh.vbnet19:56 2 May '08  
QuestionNice program...But ..... Pinmemberscotty8915:57 19 Sep '07  
GeneralVista Pinmemberlukebateson11:01 15 Aug '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120529.1 | Last Updated 20 Aug 2004
Article Copyright 2004 by kennedy_franklin
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid