Senthil Documentation
Senthil Documentation
Submitted By
SENTHILKUMARAN.K
(REG.NO-09296504)
1
`
CERTIFICATE
Dr.S.Sekar Dr.M.Govindaraj
2
`
MR.M.GOVINDARAJ,Msc, M.Phil.,M.Tech.
Lecturer,
Department of Computer Science & Applications,
Bharathidasan University,
Tiruchirapalli – 620 024.
Date:
BONAFIDE CERTIFICATE
3
`
4
`
DECLARATION
5
`
ACKNOWLEDGEMENT
6
`
giving me this ample opportunity to do this course and their kind, care and guidance.
Mr.M.GOVINDARAJ, Msc,M.Phil.,M.Tech.,for her help, valuable and kind guidance and personal
I also express my sincere thanks to HCL Infotech Chennai for giving me an opportunity to do
the project and for his valuable guidance throughout my project work.
Finally I thank all faculty members in Department of Management, UDC of Arts and Science, My
Parents, My Family Members and My Friends who have directly or indirectly helped me to successfully
SYNOPSIS
The Project Entitled “Window Management Instrumentation” aims at monitoring the remote
machine information in a interconnected environment. The development process includes the
design of control library named as WMIControlLibrary which contains four user controls. The
7
`
four user controls are as follows: Explorer, SystemInfo, Services, and Processes. Each one of
these controls does its own specific task. Brief description of what each one of these control
does.
• Explorer Control - we converted 'My Explorer' to a user control, it still display your
system drives, directories, and files information.
• SystemInfo Control* - This control display operating system information and hardware
data and specifications.
• Services Control* - This control display services currently running on the system.
• Process Control* - This control display processes currently running on the system.
(* Note: This control can be used to monitor local or remote system on the network.)
Every one of these controls uses the System.Management namespace to access their own specific
system information.
8
`
CONTENTS
9
1.0 PROJECT DESCRIPTION 14
1.1 INTRODUCTION 14
`
1.2 EXISTING SYSTEM 14
1.3 PROPOSED SYSTEM 14
1.4 WIN-32 API 15
1.5 MODULES IN DETAIL 15
1.5.1 EXPLORER CONTROLS 16
1.5.2 SYSTEM INFO CONTROLS 17
1.5.3 SERVICE CONTROLS 18
1.5.4 PROCESS CONTROLS 19
1.6 HARDWARE SPECIFICATION 21
1.7 SOFTWARE SPECIFICATION 21
2.0 SOFTWARE DESCRIPTION 22
2.1 VISUAL BASIC .NET 22
2.1.1 POWERFUL WINDOWS BASED 22
APPLICATION
2.1.2 BULIDING WEB-BASED 22
APPLICATION
2.1.3 SIMPLIFIED DEVELOPMENT 23
2.2 POWERFUL , FEEXIABLE , 23
SIMPLIFIED DATA ACCESS
2.2.1 IMPROVED CODING 23
2.2.2 DIRECT ACCESS TO PLATFORM 23
2.2.3FULL OBJECT ORIENTED 23
CONTROLS
2.3 XML WEB SERVICES 24
2.3.1 MOBLIE APPLICATION 24
2.3.2 COM INTEROPERABILITY 24
2.3.3 REUSE EXISTING INVESTMENT 25
2.3.4 UPGRADE WIZARD 25
10
3.0 TESTING
TESTING OBJECTIVE 27
`
11
`
1.1 INTRODUCTION
Remote Desktop Connection (RDC, also called Remote Desktop, formerly known
as Microsoft Terminal Service Client, or mstsc) is the client application for Remote Desktop
Services. It allows a user to remotely log in to a networked computer running the terminal
services server. RDC presents the desktop interface of the remote system, as if it were
accessed locally The server should have the ability to minimize ,maximize or close those
applications on the client's desktop.
It should not follow RDP protocol or remote desktop protocol in windows xp
protocol.But it should be running in windows xp environment.
Both the systems should be working simultaneously and there should be no user
name and password conventions in this application.The application should simply work based
on the IP address and port number.
12
`
Client A Client C
13
`
created Microsoft Visual Basic as a true graphical programming environment. Visual Basic used
a different and simpler language, called Basic as its foundation.
• Explorer Control - I converted 'My Explorer' to a user control, it still display your system
drives, directories, and files information.
• SystemInfo Control* - This control display operating system information and hardware
data and specifications.
• Services Control* - This control display services currently running on the system.
• Process Control* - This control display processes currently running on the system. (*
Note: This control can be used to monitor local or remote system on the network.)
Every one of these controls uses the System.Management namespace to access their own specific
system information.
14
`
In the Explorer control, I used the WMI Win32_LogicalDisk class to get all the local and
mapped drives on the local machine. To get access to drives information, I need to use the
ManagementObjectSearcher class to obtain a ManagementOjbectCollection class containing the
drive information.
I requested. We now have all the available drives' information at our disposal (such as drive
name, type, volume, description, etc...).
Unfortunately, it proved almost impossible to find any references to the interfaces
necessary to do the job.
15
`
The SystemInfo control display many different types of information about your local machine or
a remote machine on the network. It first establishes a ConnectionOptions object with the
UserName and Password properties set. Then it creates a ManagementScope object with the
local or remote host name and the ConnectionOptions object as the parameters.
Now we are ready to access the system information by creating an ObjectQuery member object
and passing it along with the ManagementScope object in to the ManagementObjectSearcher
member object and invoke the Get() method to execute the command.
If you are only concerned about the local host information, you can avoid the creation of
ConnectionOption, ManagementScope, and ObjectQuery objects. All you need to do is just call
the ManagementObjectSearcher member object with the query string and execute the
ManagementObjectSearcher.Get() method to get the ManagementObjectCollection result back,
for the local machine.
16
`
The SystemInfo control also displays the following information about the computer system being
accessed: System Manufacturer, Processor, Bios, Time Zone, Memory, Network Connection,
and Video Controller. The codes for these different queries are repetitive, it's just the query string
and the result properties are different.
to retrieve all the services information in the system. To start or stop a service, I dynamically
create a popup menu to the ListView.
When you right click on an item, a start or stop menu pops up, depending on the service state.
When the MenuItem is clicked, I need to get the ManagementObject for that service with this
query.
17
`
Then I call the ManagementObject.InvokeMethod() to start or stop the service. The first
parameter in the InvokeMethod method is the Observer parameter. I pass in a
ManagementOperationObserver class to manage asynchronous operations and handle
management information and events received asynchronously. By checking the returnValue
property in completionHandlerObj.ReturnObject, I can determine if the operation was successful
or not.
The Process control display the system running processes, user that started the process, CPU
utilization, and memory usage.
To get the process user, I need to call the GetOwner(User, Domain) method. The User and
Domain parameters are output parameters. How do we get to these output parameters from
InvokeMethod.
18
`
But if we need to manage asynchronous operations, then we do not need to pass in any
parameters to InvokeMethod method. You will get the output parameters from the
completionHandlerObj.ReturnObject properties collection.
19
`
20
`
Visual Basic .NET provides the easiest, most productive language and tool
for rapidly building Windows and Web applications. Visual Basic .NET comes with enhanced
visual designers, increased application performance, and a powerful integrated development
environment (IDE). It also supports creation of applications for wireless, Internet-enabled hand-
held devices. The following are the features of Visual Basic .NET with .NET Framework 1.0 and
Visual Basic .NET 2003 with .NET Framework 1.1. This also answers why should I use Visual
Basic .NET, what can I do with it?
Visual Basic .NET comes with features such as a powerful new forms designer, an
in-place menu editor, and automatic control anchoring and docking. Visual Basic .NET delivers
new productivity features for building more robust applications easily and quickly. With an
improved integrated development environment (IDE) and a significantly reduced startup time,
Visual Basic .NET offers fast, automatic formatting of code as you type, improved IntelliSense,
an enhanced object browser and XML designer, and much more.
With Visual Basic .NET we can create Web applications using the shared Web Forms
Designer and the familiar "drag and drop" feature. You can double-click and write code to
respond to events. Visual Basic .NET 2003 comes with an enhanced HTML Editor for working
with complex Web pages. We can also use IntelliSense technology and tag completion, or
choose the WYSIWYG editor for visual authoring of interactive Web applications.
21
`
With Visual Basic .NET we can build applications more rapidly and deploy and
maintain them with efficiency. Visual Basic .NET 2003 and .NET Framework 1.1 makes "DLL
Hell" a thing of the past. Side-by-side versioning enables multiple versions of the same
component to live safely on the same machine so that applications can use a specific version of a
component. XCOPY-deployment and Web auto-download of Windows-based applications
combine the simplicity of Web page deployment and maintenance with the power of rich,
responsive Windows-based applications.
You can tackle any data access scenario easily with ADO.NET and ADO data
access. The flexibility of ADO.NET enables data binding to any database, as well as classes,
collections, and arrays, and provides true XML representation of data. Seamless access to ADO
enables simple data access for connected data binding scenarios. Using ADO.NET, Visual
Basic .NET can gain high-speed access to MS SQL Server, Oracle, DB2, Microsoft Access, and
more.
You can code faster and more effectively. A multitude of enhancements to the
code editor, including enhanced IntelliSense, smart listing of code for greater readability and a
background compiler for real-time notification of syntax errors transforms into a rapid
application development (RAD) coding machine.
Visual Basic developers can have full access to the capabilities available in
.NET Framework 1.1. Developers can easily program system services including the event log,
performance counters and file system. The new Windows Service project template enables to
build real Microsoft Windows NT Services.
22
`
Programming against Windows Services and creating new Windows Services is not available in
Visual Basic .NET Standard, it requires Visual Studio 2003 Professional, or higher.
XML Web services enable you to call components running on any platform
using open Internet protocols. Working with XML Web services is easier where enhancements
simplify the discovery and consumption of XML Web services that are located within any
firewall. XML Web services can be built as easily as you would build any class in Visual Basic
6.0. The XML Web service project template builds all underlying Web service infrastructure.
Visual Basic .NET 2003 and the .NET Framework 1.1 offer integrated support
for developing mobile Web applications for more than 200 Internet-enabled mobile devices.
These new features give developers a single, mobile Web interface and programming model to
support a broad range of Web devices, including WML 1.1 for WAP—enabled cellular phones,
compact HTML (cHTML) for i-Mode phones, and HTML for Pocket PC, handheld devices, and
pagers. Please note, Pocket PC programming is not available in Visual Basic .NET Standard, it
requires Visual Studio 2003 Professional, or higher.
23
`
In addition, full support for existing ADO code and data binding enable a smooth transition to
Visual Basic .NET 2003.
24
`
25
`
As per seven laws of computing “Any non-trivial program contains at least one
bug. These are no trivial programs”. The proper choice of test data is an important as the
test itself so; live data has been collected for testing.
The modules of the system are tested as an individual in unit testing; each unit has
definite input and output parameters.
In this type of testing, the application is tested until it does something. A is not
suppose to do.
This test provides, that each individual window (print, record, menus, message box) that
the system consists of has been designed and built according to project standards.
26
`
This testing method ensures that the nuts and bolts functions of the system are
actually tested.
The aim of the integration test is to put together the individually unit tested pages
and build program structure; while at the some time tests are conducted to uncover errors
associated with interfacing of pages.
In this test this program goes smoothly from starting end. If we give any wrong
input it display error message immediately. Display output are tested and verified.
This determines the length of time by the system to process transaction of data.
For ex, the response times in case of an inquiry of the system
27
`
28
`
In order for remote desktop to work, you have to set a password on your user account. Follow
these steps to set a password.
Now you’re ready to enable remote desktop. You have to be logged in as an administrator
1. Go to Start then right click on My Computer (or right click My Computer on your
desktop)
29
`
2. Select Properties
3. Go to the Remote tab
4. Check “Allow users to connect remotely to this computer”
5. If you have other users that you want to allow remote access to the computer then go to
Select Remote Users and select add and type in the user account name of the user where
it says “Enter the object names to select”
Now, this is how to connect to your computer from using Remote Desktop Connection. If you’re
using a computer that doesn’t have Windows XP then you can load the client side of Remote
Desktop Connection. Get it at and then you can follow these steps.
1. Go to Start
2. Go to All Programs
3. Go to Accessories
4. Go to Communications
5. Click Remote Desktop Connection
6. Go to Options and modify the options as you seem fit
7. Type in your IP address by 'Computer'
8. Log in with your username and password
You should now have access to your computer. Take note that playing music will not work well
with over the remote connection unless you have it stay at the local computer (change this in the
options). Also, if you view images and webpages over the connection it will be very slow. Oh,
and of course, you can’t play games like Quake 3 over the connection, this simply isn’t possible.
30
`
• You can keep your IRC (internet relay chat) and IM clients open on one machine and
then connect to your computer from other places. Thus you don’t have to leave your
screen names and whatnot behind on other people’s computers.
• Check and save email in YOUR email client instead of using webmail.
• Perhaps your workplace/school doesn’t allow you to run IRC or IM clients, but you can
use remote desktop. Then you can log on to your computer and IRC and IM from there.
• You could use this as some sort of tech support method.
• You can use Remote Desktop if you can’t always have a monitor plugged in to the box.
• Great for servers, you don't need to buy keyboard, mouse, monitor etc. to use.
4.4 Cons
System info:
31
`
4.6 Explorer:
.4.7Service form:
32
`
33
`
bitmap with
transparent or
semitransparent
pixels.
BitBlt Performs a bit- System.Drawing.Graphics.DrawImage
block transfer.
CreateBitmap Creates a System.Drawing.Bitmap constructor
bitmap.
Note Creates a DIB, not a DDB.
GetBitmapDimensionEx Gets the System.Drawing.Bitmap.Size
dimensions of a
bitmap.
GetDIBColorTable Retrieves RGB System.Drawing.Bitmap.Palette
color values
from a DIB
section bitmap.
GetDIBits Copies a System.Drawing.Bitmap.LockBits
bitmap into a
buffer.
GetPixel Gets the RGB System.Drawing.Bitmap.GetPixel
color value of
the pixel at a
given
coordinate.
GradientFill Fills rectangle System.Drawing.Graphics.FillRectangle(Drawing2D.LinearGr
and triangle adiantBrush, Rectangle)
structures.
LoadBitmap Loads a bitmap System.Drawing.Bitmap.Bitmap(Type, String)
from a
module's
executable file.
Set Sets System.Drawing.Bitmap.SetPixel
Pixel the color for a
pixel.
SetPixelV Sets a pixel to System.Drawing.Bitmap.SetPixel(…,
the best Graphics.GetNearestColor(Color))
approximation
of a color.
StretchBlt Copies a System.Drawing.Graphics.DrawImage
bitmap and
stretches or
Brush Functions
34
`
35
`
Secpol.msc
Network access Classic
3.My Computer
*Manage
*WMI Program
*WMI Services
*Properties
*Logging on
*Assign Verbose
*WMI control
*Security
*Allow all user
3.Fire wall
*Exception
*Check all the boxes
*Apply
4.Password
*Users
*Set Password
*Apply
Run Command
Services.msc:
36
`
Network Sharing:
COM+EVENT
37
`
COM+SYSTEM APPLICATION
38
`
Telnet:
39
`
2. Go to Run Command:
40
`
Network access:
41
`
My Computer
*Manage
42
`
WMI Program:
WMI Services:
43
`
Assign Verbose:
44
`
3.Firewall:
Exception:
Check all the boxes
Password:
46
`
Set Password:
47
`
using System;
using System.Management;
namespace completionHandler
{
/// <summary>
/// MyHandler class handle notification when InvokeMethod call is complete
/// </summary>
public class MyHandler
{
private bool isComplete = false;
private ManagementBaseObject returnObject;
/// <summary>
/// Trigger Done event when InvokeMethod is complete
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void Done(object sender, ObjectReadyEventArgs e)
{
isComplete = true;
returnObject = e.NewObject;
}
/// <summary>
/// Get property IsComplete
/// </summary>
public bool IsComplete
{
get
{
49
`
return isComplete;
}
}
/// <summary>
/// Property allows accessing the result object in the main function
/// </summary>
public ManagementBaseObject ReturnObject
{
get
{
return returnObject;
}
}
}
}
2. process dictionary
using System;
using System.Collections.Specialized;
namespace ProcessesDictionary
{
/// <summary>
///
/// </summary>
public struct structProcessInfo
{
public string stringName;
public string stringProcessID;
public string stringParentProcessID;
50
`
51
`
52
`
using System;
using System.Collections.Specialized;
namespace ProcessesPerformanceDictionary
{
/// <summary>
/// Process performance data structure
/// </summary>
public struct structPerformance
{
public string stringPercentProcessorTime;
public string stringVirtualBytes;
}
public class ProcessPerf
{
private structPerformance _value;
/// <summary>
/// Property
/// </summary>
public structPerformance Value
{
get {return _value;}
set {_value = value;}
} }
/// <summary>
/// This Dictionary contains process performance data.
53
`
/// </summary>
public class Dictionary : NameObjectCollectionBase
{
/// <summary>
/// Clear dictionary
/// </summary>
public void Clear()
{
BaseClear();
}
/// <summary>
/// Add item to dictionary
/// </summary>
/// <param name="name"></param>
/// <param name="processPerformance"></param>
public void Add(string name, ProcessPerf processPerformance)
{
BaseAdd(name, processPerformance);
}
/// <summary>
/// Remove item from dictionary by key
/// </summary>
/// <param name="name"></param>
public void Remove(string name)
{
BaseRemove(name);
}
/// <summary>
/// Remove item from dictionary by index
/// </summary>
/// <param name="index"></param>
54
`
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Management;
namespace WindowsServicesControlLibrary
55
`
{
/// <summary>
/// Display srvices informatin.
/// </summary>
public class Srvices : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ListView listViewServices;
private System.Windows.Forms.Button buttonRefresh;
private System.Windows.Forms.RadioButton radioRemoteMachine;
private System.Windows.Forms.TextBox textPassword;
private System.Windows.Forms.TextBox textUserID;
private System.Windows.Forms.Label labelPassword;
private System.Windows.Forms.Label labelUserID;
private System.Windows.Forms.Label labelIP;
private System.Windows.Forms.TextBox textIP;
private System.Windows.Forms.RadioButton radioMachine;
public event Status UpdateStatus;
private string stringServiceName = "";
private string stringServiceAction = "";
private ListViewItem listViewServiceItem;
private bool boolLoaded = false;
public Srvices()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// Init list view
InitListView();
// Init boolLoaded flag
boolLoaded = false;
}
56
`
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
57
`
this.imageList = new
System.Windows.Forms.ImageList(this.components);
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
this.panel1.Location = new System.Drawing.Point(632, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(128, 512);
this.panel1.TabIndex = 0;
//
// buttonRefresh
//
this.buttonRefresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonRefresh.Location = new System.Drawing.Point(29, 16);
this.buttonRefresh.Name = "buttonRefresh";
this.buttonRefresh.Size = new System.Drawing.Size(75, 24);
this.buttonRefresh.TabIndex = 10;
this.buttonRefresh.Text = "&Refresh";
this.buttonRefresh.Click += new
System.EventHandler(this.buttonRefresh_Click);
//
// radioRemoteMachine
//
this.textPassword.Location = new System.Drawing.Point(13, 272);
this.textPassword.Name = "textPassword";
this.textPassword.PasswordChar = '*';
this.textPassword.Size = new System.Drawing.Size(104, 20);
this.textPassword.TabIndex = 18;
58
`
this.textPassword.Text = "";
this.textPassword.Visible = false;
//
// textUserID
//
this.textUserID.Location = new System.Drawing.Point(13, 208);
this.textUserID.Name = "textUserID";
this.textUserID.Size = new System.Drawing.Size(104, 20);
this.textUserID.TabIndex = 16;
this.textUserID.Text = "";
this.textUserID.Visible = false;
//
// labelPassword
//
this.labelPassword.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.labelPassword.Location = new System.Drawing.Point(13, 248);
this.labelPassword.Name = "labelPassword";
this.labelPassword.Size = new System.Drawing.Size(100, 16);
this.labelPassword.TabIndex = 17;
this.labelPassword.Text = "&Password:";
this.labelPassword.Visible = false;
//
// labelUserID
//
this.labelUserID.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.labelUserID.Location = new System.Drawing.Point(13, 184);
this.labelUserID.Name = "labelUserID";
this.labelUserID.Size = new System.Drawing.Size(100, 16);
this.labelUserID.TabIndex = 15;
this.labelUserID.Text = "&User ID:";
this.labelUserID.Visible = false;
59
`
//
// labelIP
//
this.labelIP.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.labelIP.Location = new System.Drawing.Point(13, 120);
this.labelIP.Name = "labelIP";
this.labelIP.Size = new System.Drawing.Size(112, 16);
this.labelIP.TabIndex = 13;
this.labelIP.Text = "&IP or Machine Name:";
this.labelIP.Visible = false;
//
// textIP
//
this.textIP.Location = new System.Drawing.Point(13, 144);
this.textIP.Name = "textIP";
this.textIP.Size = new System.Drawing.Size(104, 20);
this.textIP.TabIndex = 14;
this.textIP.Text = "";
this.textIP.Visible = false;
//
// radioMachine
//
this.radioMachine.Checked = true;
this.radioMachine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.radioMachine.Location = new System.Drawing.Point(13, 56);
this.radioMachine.Name = "radioMachine";
this.radioMachine.Size = new System.Drawing.Size(120, 24);
this.radioMachine.TabIndex = 11;
this.radioMachine.TabStop = true;
this.radioMachine.Text = "&Current Machine";
60
`
this.radioMachine.CheckedChanged += new
System.EventHandler(this.radioMachine_CheckedChanged);
System.Windows.Forms.SortOrder.Ascending;
this.listViewServices.TabIndex = 1;
this.listViewServices.View = System.Windows.Forms.View.Details;
this.listViewServices.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.listViewServices_MouseDown);
//
// imageList
//
this.imageList.ColorDepth =
System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList.ImageSize = new System.Drawing.Size(16, 16);
this.imageList.ImageStream
/// <summary>
/// Get services and populate list view
/// </summary>
private void getServices()
{
ManagementObjectCollection queryCollection;
string[] lvData = new string[4];
try
{
queryCollection = getServiceCollection("SELECT * FROM
Win32_Service");
foreach ( ManagementObject mo in queryCollection)
{
//create child node for operating system
lvData[0] = mo["Name"].ToString();
lvData[1] = mo["StartMode"].ToString();
61
`
if (mo["Started"].Equals(true))
lvData[2] = "Started";
else
lvData[2] = "Stop";
lvData[3] = mo["StartName"].ToString();
//Status
updateStatus("Ready");
this.Update();
/// <summary>
/// Update status
/// </summary>
/// <param name="stringStatus"></param>
private void updateStatus(string stringStatus)
{
if (UpdateStatus != null)
62
`
UpdateStatus(stringStatus );
}
/// <summary>
/// radioMachine_CheckedChanged event allow user to access services on other
machine
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void radioMachine_CheckedChanged(object sender, System.EventArgs e)
{
bool booleanFlag = true;
RadioButton rbClicked = (RadioButton) sender;
//toggle controls
labelIP.Visible = booleanFlag;
textIP.Visible = booleanFlag;
labelUserID.Visible = booleanFlag;
textUserID.Visible = booleanFlag;
labelPassword.Visible = booleanFlag;
textPassword.Visible = booleanFlag;
/// <summary>
/// buttonRefresh click event allow user to refresh service list view
/// </summary>
/// <param name="sender"></param>
63
`
/// <summary>
/// List view mouse down event to built context menu dynamically
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <summary>
/// List view context menu click event to invoke start/stop service
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem_Click(object sender, System.EventArgs e)
{
ManagementObjectCollection queryCollection;
ListViewItem lvItem;
64
`
//Status
updateStatus("Starting/Stopping service...");
//increment counter
intCount++;
}
65
`
if
(completionHandlerObj.ReturnObject.Properties["returnValue"].Value.ToString() == "0")
{
//succeeded
lvItem = ServiceItem;
if (ServiceAction == "StartService")
lvItem.SubItems[2].Text = "Started";
else
lvItem.SubItems[2].Text = "Stop";
}
else
{
//error message
string stringAction;
if (ServiceAction == "StartService")
stringAction = "start";
else
stringAction = "stop";
//clean-up objects
ServiceName = "";
ServiceAction = "";
ServiceItem = null;
//Status
66
`
updateStatus("Ready");
this.Update();
}
/// <summary>
/// Get computer service collection
/// </summary>
/// <param name="stringQuery"></param>
/// <returns>queryCollection</returns>
private ManagementObjectCollection getServiceCollection(string stringQuery)
{
ManagementObjectSearcher query;
ManagementObjectCollection queryCollection = null;
System.Management.ObjectQuery oq;
string stringMachineName = "";
if (radioMachine.Checked == true)
{
stringMachineName = "localhost";
}
else
{
stringMachineName = textIP.Text;
}
if (stringMachineName.Trim().Length == 0)
{
MessageBox.Show("Must enter machine IP address or name.");
67
`
return null;
}
//Point to machine
System.Management.ManagementScope ms = new
System.Management.ManagementScope("\\\\" + stringMachineName + "\\root\\cimv2", co);
//Status
updateStatus("Getting Services Information");
try
{
queryCollection = query.Get();
}
catch (Exception e1)
{
MessageBox.Show("Error: " + e1);
}
68
`
//Status
updateStatus("Ready");
this.Update();
return queryCollection;
}
/// </summary>
public override void Refresh()
{
// Init list view
InitListView();
getServices();
boolLoaded = true;
}
/// <summary>
/// GetLoaded check if control was loaded before
/// </summary>
/// <returns></returns>
public bool Loaded
{
get
{
//true if control already loaded else false.
return boolLoaded;
}
}
}
69
`
70
`
7.0 Conclusion:
Thus the project WMI has been successfully designed and executed well in the specified
Environment that is the Windows environment, during the project, the product we
developed has undergone all the life cycle phases of the project and it meet the standards
which are needed for a commercial tool in the windows platform, further we also like to
add more features in the system to upgrade the tool for the next version.
71
`
72
`
8.0BIBLIOGRAPHY
*VC#.NET, James Goodwill,G.C.Jain for Techmedia, FIRST INDIAN EDITION
VC#.NET COMPLETE REFERENCE, Herbert Schildt,3rd Edition, Mc Graw Hill
*WWW.MICROSOFT.COM.
73