Click here to Skip to main content
16,016,140 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 308.9K   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

 
GeneralNot shows the list of computers Pin
Rajkumar S. Rajput2-May-07 1:18
Rajkumar S. Rajput2-May-07 1:18 
QuestionHow to receive message? Pin
testmail_12322-Feb-07 19:39
testmail_12322-Feb-07 19:39 
AnswerRe: How to receive message? Pin
vsuguna10-Oct-09 2:29
vsuguna10-Oct-09 2:29 
GeneralDue to XP service pk2 this kind of messenger services has been disabled [modified] Pin
godsemporer13-Aug-06 13:52
godsemporer13-Aug-06 13:52 
Generalthank you Pin
jimbo_azim12-Jun-06 18:45
jimbo_azim12-Jun-06 18:45 
GeneralRe: thank you Pin
diasroyal8-Jul-11 4:35
diasroyal8-Jul-11 4:35 
Generalthank you any way Pin
osamahamed12325-Feb-06 23:56
osamahamed12325-Feb-06 23:56 
GeneralShutup Pin
Mike K. Clark26-Jan-06 15:13
Mike K. Clark26-Jan-06 15:13 
For you people ranting and raving about how his "Stupid worthless" program doesn't work "I can't see a list of my lan", "It isn't connecting" its called a god damn firewall, I will bet 95% of you people are using this application in a corporate controlled or school like environment (and sense most of your signatures say "Software Engineer" it makes me question how intelligent you really are when it comes to this stuff). The settings "In your environment" probably don't allow a netsend connection (most don't, it opens up vulnerability to hackers). If your complaining about how he used the NetSend Function instead of the NetServerEnum Function
take the appsource that supposedly took 30 minutes to code and fix it yourself your all software engineers (at least it says so in your signatures). He didn't make this application to please individual people. So honestly if you have a problem with the source code or question post a question about it. And dude with the 14.4 kbps modem your system sounds so old do you even have the .Net Framework installed to execute the application?? Does your dinosour even support it??

Thank you

~ Mike
Generalnice appn but getting problem with net send Pin
mamatharaghu19-Oct-05 21:06
mamatharaghu19-Oct-05 21:06 
GeneralIf you've nothing contructive to say, move on Pin
Like2Byte19-Jul-05 8:18
Like2Byte19-Jul-05 8:18 
General[Message Deleted] Pin
PERREO PAPI PERREO9-Jul-05 13:03
sussPERREO PAPI PERREO9-Jul-05 13:03 
GeneralRe: it suks Pin
Colin Angus Mackay9-Jul-05 13:26
Colin Angus Mackay9-Jul-05 13:26 
GeneralRe: it suks Pin
greg.boudreau16-Jul-07 4:22
greg.boudreau16-Jul-07 4:22 
Generalnice program Pin
Klaasjan Mors14-Apr-05 11:08
Klaasjan Mors14-Apr-05 11:08 
GeneralIt doesn't work Pin
ladwal6-Jan-05 21:48
ladwal6-Jan-05 21:48 
Generalplcation.Doesn't work Pin
ladwal6-Jan-05 21:46
ladwal6-Jan-05 21:46 
QuestionHow do i..... Pin
Member 58244512-Sep-04 20:49
Member 58244512-Sep-04 20:49 
AnswerRe: How do i..... Pin
diasroyal8-Jul-11 5:30
diasroyal8-Jul-11 5:30 
GeneralTHIS IS COMPLETE GARBAGE Pin
Anonymous20-Aug-04 10:49
Anonymous20-Aug-04 10:49 
GeneralRe: THIS IS COMPLETE GARBAGE Pin
Franklin Kennedy21-Aug-04 8:35
sussFranklin Kennedy21-Aug-04 8:35 
GeneralRe: THIS IS COMPLETE GARBAGE Pin
Meysam Mahfouzi23-Aug-04 20:19
Meysam Mahfouzi23-Aug-04 20:19 
GeneralRe: THIS IS COMPLETE GARBAGE Pin
sadbuttrue25-Aug-04 1:49
sadbuttrue25-Aug-04 1:49 
GeneralRe: THIS IS COMPLETE GARBAGE Pin
Anonymous21-Mar-05 8:25
Anonymous21-Mar-05 8:25 
GeneralRe: THIS IS COMPLETE GARBAGE Pin
dsyeey20-Mar-11 0:11
dsyeey20-Mar-11 0:11 
GeneralGood job, but... Pin
Ellery_Familia20-Aug-04 4:43
Ellery_Familia20-Aug-04 4:43 

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.