Click here to Skip to main content
15,860,861 members
Articles / Programming Languages / XML

LAN Messenger

Rate me:
Please Sign up or sign in to vote.
3.26/5 (36 votes)
19 Aug 20042 min read 301.6K   10.2K   84   63
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.

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

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

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

VB
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”.

VB
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:

VB
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.


Written By
Web Developer
Kuwait Kuwait
I am J. Franklin Kennedy, Working as a programmer in application software developement.


Comments and Discussions

 
QuestionNot working after download Pin
Dalwadi Tushar7-Nov-21 22:18
Dalwadi Tushar7-Nov-21 22:18 
QuestionCustom Naming Pin
Member 1067161312-Mar-20 13:04
Member 1067161312-Mar-20 13:04 
Questionnot working Pin
Member 1377184310-Apr-18 1:16
Member 1377184310-Apr-18 1:16 
GeneralGreat App Pin
Member 996501014-Jan-16 1:14
Member 996501014-Jan-16 1:14 
Questionnot working on windows 7 Pin
Member 1189890412-Aug-15 6:15
Member 1189890412-Aug-15 6:15 
QuestionSource code not working on VS 2013 Pin
Shivam_Srivastava21-Jul-15 19:46
Shivam_Srivastava21-Jul-15 19:46 
AnswerRe: Source code not working on VS 2013 Pin
Member 136316456-Mar-18 19:00
Member 136316456-Mar-18 19:00 
QuestionGreat Start Pin
fuqueue8418-Jul-12 5:04
fuqueue8418-Jul-12 5:04 
Questionasp.net,c# Pin
NaniCh8-Jul-12 22:58
NaniCh8-Jul-12 22:58 
QuestionSending a message Pin
Kwaku Boateng2-Jun-12 13:37
Kwaku Boateng2-Jun-12 13:37 
GeneralMy vote of 5 Pin
Muhammad Wilayat Shah21-Mar-12 9:35
Muhammad Wilayat Shah21-Mar-12 9:35 
Question[My vote of 2] not great Pin
BillW3317-Feb-12 2:27
professionalBillW3317-Feb-12 2:27 
Questionhelp regarding the file transfer Pin
Menon Santosh13-Feb-12 18:41
professionalMenon Santosh13-Feb-12 18:41 
GeneralMy vote of 5 Pin
Mojtaba Rezaeian3-Dec-11 15:04
Mojtaba Rezaeian3-Dec-11 15:04 
Questionat kennedsy_franklin Pin
Monib zia9-Oct-11 3:16
Monib zia9-Oct-11 3:16 
QuestionWhere can i do the editing of this software from?? Pin
diasroyal8-Jul-11 5:20
diasroyal8-Jul-11 5:20 
GeneralMy vote of 4 Pin
diasroyal8-Jul-11 4:01
diasroyal8-Jul-11 4:01 
QuestionNot working Pin
pankaj11256-Jul-11 22:28
pankaj11256-Jul-11 22:28 
Hello Sir,
I am trying to send message in Lan but it not displaying on other machine.
I want client program on which sent message will display. Please help.
GeneralMy vote of 1 Pin
Arpan Kar24-Apr-11 23:06
Arpan Kar24-Apr-11 23:06 
Questionmessage is not being sent Pin
RAHUL238530-Dec-10 22:46
RAHUL238530-Dec-10 22:46 
AnswerRe: message is not being sent Pin
elpaez25-Nov-11 8:49
elpaez25-Nov-11 8:49 
Generalmessenger Pin
Ramani Nidhi18-Apr-09 19:54
Ramani Nidhi18-Apr-09 19:54 
GeneralRe: messenger Pin
IshanLakhia26-Apr-09 21:48
IshanLakhia26-Apr-09 21:48 
GeneralRe: messenger Pin
diasroyal8-Jul-11 4:13
diasroyal8-Jul-11 4:13 
Generalhelp me to operate a lan messenger Pin
vahid1460712-Nov-08 20:44
vahid1460712-Nov-08 20:44 

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

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