Prizes & Awards
My Profile
Active Members
TodayLast 7 Days
more...
|
Resources » Articles » .NET Framework »
Intranet messenger
|
Imports System.DirectoryServices Public Class Form1 Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New() MyBase.New()
'This call is required by the Windows Form Designer. InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub
'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents txtMessage As System.Windows.Forms.TextBox Friend WithEvents txtComputer As System.Windows.Forms.TextBox Friend WithEvents btnSend As System.Windows.Forms.Button Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox Friend WithEvents TreeView1 As System.Windows.Forms.TreeView Private Sub InitializeComponent() Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.txtMessage = New System.Windows.Forms.TextBox Me.txtComputer = New System.Windows.Forms.TextBox Me.btnSend = New System.Windows.Forms.Button Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.TreeView1 = New System.Windows.Forms.TreeView Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.SuspendLayout() ' 'GroupBox1 ' Me.GroupBox1.BackColor = System.Drawing.SystemColors.Control Me.GroupBox1.Controls.Add(Me.txtMessage) Me.GroupBox1.Controls.Add(Me.txtComputer) Me.GroupBox1.Controls.Add(Me.btnSend) Me.GroupBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.GroupBox1.Location = New System.Drawing.Point(152, 0) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(288, 160) Me.GroupBox1.TabIndex = 3 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Message" ' 'txtMessage ' Me.txtMessage.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtMessage.ForeColor = System.Drawing.SystemColors.HotTrack Me.txtMessage.Location = New System.Drawing.Point(8, 24) Me.txtMessage.Multiline = True Me.txtMessage.Name = "txtMessage" Me.txtMessage.Size = New System.Drawing.Size(272, 88) Me.txtMessage.TabIndex = 1 Me.txtMessage.Text = "" ' 'txtComputer ' Me.txtComputer.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper Me.txtComputer.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtComputer.ForeColor = System.Drawing.Color.Red Me.txtComputer.Location = New System.Drawing.Point(8, 120) Me.txtComputer.Multiline = True Me.txtComputer.Name = "txtComputer" Me.txtComputer.Size = New System.Drawing.Size(144, 24) Me.txtComputer.TabIndex = 4 Me.txtComputer.Text = "" ' 'btnSend ' Me.btnSend.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnSend.ForeColor = System.Drawing.Color.Navy Me.btnSend.Location = New System.Drawing.Point(192, 120) Me.btnSend.Name = "btnSend" Me.btnSend.Size = New System.Drawing.Size(88, 32) Me.btnSend.TabIndex = 2 Me.btnSend.Text = "&Send" ' 'GroupBox2 ' Me.GroupBox2.Controls.Add(Me.TreeView1) Me.GroupBox2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.GroupBox2.Location = New System.Drawing.Point(0, 0) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(144, 160) Me.GroupBox2.TabIndex = 5 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Select Computer" ' 'TreeView1 ' Me.TreeView1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TreeView1.ForeColor = System.Drawing.Color.Red Me.TreeView1.ImageIndex = -1 Me.TreeView1.Location = New System.Drawing.Point(8, 16) Me.TreeView1.Name = "TreeView1" Me.TreeView1.SelectedImageIndex = -1 Me.TreeView1.Size = New System.Drawing.Size(128, 136) Me.TreeView1.TabIndex = 0 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(440, 165) Me.Controls.Add(Me.GroupBox2) Me.Controls.Add(Me.GroupBox1) Me.MaximizeBox = False Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "My Message" Me.GroupBox1.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click If txtComputer.Text <> "" And txtMessage.Text <> "" Then Shell("net send " & txtComputer.Text & " " & txtMessage.Text) txtMessage.Text = "" txtMessage.Focus() End If End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 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 End Sub
Private Sub TreeView1_AfterSelect_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect txtComputer.Text = TreeView1.SelectedNode.Text End Sub
End Class
|
Responses
|
| Author: Keith Mason 24 Jun 2004 | Member Level: Bronze Points : 0 | The System.DirectoryServices does not exist. Is there a new reference to add? I'm using VB.NET 2003.
| | Author: Sajjad Haider 31 Jul 2004 | Member Level: Bronze Points : 0 | This articles seems to be very good but when i try to imports Imports System.DirectoryServices in VB.NET it gives error so how can avoid from this thing
| | Author: Rudresh Kundur 20 Aug 2004 | Member Level: Bronze Points : 0 | Imports.system.DirectoryServices is not display and giving an erron please tell wether i used different header file or what.
| | Author: Sukhdev Sethi 27 Oct 2004 | Member Level: Bronze Points : 0 | To Make the Imports System.DirectoryServices work do - In Visual Studio do this: Project Menu > Add Reference... (under the .NET Tab)
Select System.DirectoryServices.dll under the component Name
Now you'll not get an error that VB.NET cannot find the reference
| | Author: rakes sharma 05 Dec 2004 | Member Level: Bronze Points : 0 | This is quite a good messenger. But we can have other options too in this messenger try it out
| | Author: vijay.c 23 Dec 2005 | Member Level: Bronze Points : 0 | This code is working but the message is not sent to the targeted machine
please help me
|
|