You are on page 1of 73

`

A STUDY ON THE REMOTE SYSTEM MONITERING THROUGH


WIN-32 API
A Project Report submitted to the
Bharathidasan University, Tiruchirappalli
In partial fulfilment of the requirements for the award of the degree of
MASTER OF BUSINESS ADMINISTRATION

Submitted By
SENTHILKUMARAN.K
(REG.NO-09296504)

Under the guidance of


MR.M.GOVINDARAJ,Msc, M.Phil.,M.Tech.
Department of Computer Science & Applications,
Bharathidasan University,
Tiruchirapalli – 620 024.

CENTER FOR DISTANCE EDUCATION


BHARATHIDASAN UNIVERSITY
TIRUCHIRAPPALLI-620024
AUGUST 2010

1
`

CENTRE FOR DISTANCE EDUCATION


BHARATHIDASAN UNIVERSITY
TIRUCHIRAPPALLI -24

CERTIFICATE

This is to certify that the dissertation entitled “REMOTE SYSTEM MONITERING


THROUGH WIN 32 API” is the bonafide work done under my supervision by
SENTHILKUMARAN.K(Reg No : 09296504) and submitted to Bharathidasan University
Tiruchirapalli in partial fulfillment of the requirements for the award of the degree of Master of
Business Administration during the academic year(2009-2010)

Signature of the Co-ordinator Signature of the Guide

Dr.S.Sekar Dr.M.Govindaraj

The viva – voice examination held was conducted on __________________at the


Bharathidasan University,Tiruchirappalli-620 024.

Internal Examiner External Examiner

2
`

MR.M.GOVINDARAJ,Msc, M.Phil.,M.Tech.
Lecturer,
Department of Computer Science & Applications,
Bharathidasan University,
Tiruchirapalli – 620 024.

Date:

BONAFIDE CERTIFICATE

This is to certify that the dissertation entitled “REMOTE


SYSTEMMONITERING THROUGH WIN 32 API” is the bonafide work done under my
supervision by SENTHILKUMARAN.K(Reg No : 09296504) and submitted to Bharathidasan
University Tiruchirapalli in partial fulfillment of the requirements for the award of the degree of
Master of Business Administration during the academic year(2009-2010)

Signature of the Guide

3
`

As the requirements needed to complete the Microsoft certificate has been


under gone by me which gained me the Microsoft certificate and awarded by the
Microsoft -MCITP PROFESSIONAL CERTIFICATION. This certification and the
guidance from the HCl has made me to develop this project successfully.

4
`

DECLARATION

I hereby declare that the work presented “REMOTE SYSTEM MONITERING


THROUGH WIN 32 API” in this dissertation is the original work done by me under
the guidance of Mr. M.GOVINDARAJ Msc,M.Phil.,M.Tech.., Lecturer, Department of
Computer Science and Applications, Bharathidasan University, Tiruchirappalli-24and has not
been included in any thesis/dissertation submitted for any other degree.

Name of the Candidate : SENTHILKUMARAN.K

Register Number : 09296504

Academic Year : 2009– 2010

Signature of the Candidate

5
`

ACKNOWLEDGEMENT

6
`

I would like to thank my Father KULASEKAR.S and my Mother PUSPHALATHA.Kfor

giving me this ample opportunity to do this course and their kind, care and guidance.

I am thankful to Dr. N.ARUMUGAM M.Com.,M.Phil.,Ph.D., DIRECTOR, CENTER FOR

DISTANCE EDUCATION, BHARATHIDASAN UNIVERSITY, TIRUCHIRAPALLI –620 023, for

his academic support to carry out his project.

I would like to thank Dr.S. SEKAR, M.Com.,M.B.A.,M.Phil.,Ph.D.,CO-ORDINATOR, MBA

CONCURRENT COURSE AT URUMU DHANALAKSHMI COLLEGE CENTER for his timely

suggestions and permission to do this project.

I wish to express my profound sense of gratitude to my Project Guide

Mr.M.GOVINDARAJ, Msc,M.Phil.,M.Tech.,for her help, valuable and kind guidance and personal

interest shown throughout my Project Work

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

complete this project.

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.

Development Tool : VC#.NET

Integerated Development Environment : Visual Studio IDE 2005

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.0 PROJECT DESCRIPTION

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
`

1.2 EXISTING SYSTEM:


The current system of WMI provided by the Microsoft will display the contents such as
processes, services and system information of the current machine. In the client server
environment the server can monitor the remote machine information such as system info,
processes and service, but the two different clients in the network cannot view the information of
one client from the other. In order to overcome this problem, a proposed system is devised based
on the functionality of the existing system. The proposed system is explained in the next section.
1.3 PROPOSED SYSTEM:
The proposed system is devised in order to overcome the defects of the existing system. In
the proposed system. The clients in the interconnected environment can view the information of
another client in the interconnected system. This functionality is made possible as follows, any
machine in the windows platform will have the default control named WMI, which is responsible
for fetching the computer’s information, thus the remote machine in the network also have the
WMI, thus we can call the remote machine’s WMI through the SNMP protocol, by doing so the
information of the remote client in the network can be accessed by another client.

Client A Client C

1.4 WIN-32 API


Win32 requires a good level of understanding and work, Microsoft released a
customized version of the Win32 library to make it easier to comprehend. The library is called
Microsoft Foundation Class Library (MFC). Because Win32 was written in C and MFC was
written for C/C++ developers, programmers of other languages would not understand it. To
accommodate others, in fact to make Windows programming accessible to everybody, Microsoft

13
`

created Microsoft Visual Basic as a true graphical programming environment. Visual Basic used
a different and simpler language, called Basic as its foundation.

1.5 Modules in Detail


In this project I have created a WMIControlLibrary which contains four user controls. The
four user controls are as follows: Explorer, SystemInfo, Services, and Processes. Each one of
these controls does its own specific task. Here is a brief description of what each one of these
control does.

• 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
`

1.5.1 Explorer Control

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
`

1.5.2 SystemInfo Control

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.

1.5.3 Service Control


The Service control uses the query:

SELECT * FROM Win32_Service

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
`

SELECT * FROM Win32_Service WHERE Name = 'ServiceName'.

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.

1.5.4 Process Control

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
`

This depends on how we implement the InvokeMethod. If we do not need to manage


asynchronous operations, then we need to pass in a string[] to the InvokeMethod method to
retrieve the output parameters.

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
`

1.6 HARDWARE SPECIFICATION:


PROCESSOR -- PENTIUM 111
SPEED -- 700 MHZ
MAIN MEMORY -- 256 MB
KEY BOARD -- RITCOMP 2098- CHERRY SOFT
MOUSE -- LOGITECH
MONITOR -- SAMTEL COLOR MONITOR
HARDDISK -- 10 GB
FLOPPY DRIVE -- 1.44 MB
CD DRIVE -- 50X MAX

1.7 SOFTWARE SPECIFICATION:

FRONT END TOOLS : VC#.NET


OPERATING SYSTEM : WINDOWS XP

20
`

2.0 SOFTWARE DESCRIPTION

2.1 Visual Basic .NET

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?

2.1.1 Powerful Windows-based Applications

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.

2.1.2 Building Web-based Applications

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
`

2.1.3 Simplified Deployment

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.

2.2 Powerful, Flexible, Simplified Data Access

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.

2.2.1 Improved Coding

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.

2.2.2 Direct Access to the Platform

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.

2.2.3 Full Object-Oriented Constructs


You can create reusable, enterprise-class code using full object-oriented
constructs. Language features include full implementation inheritance, encapsulation, and
polymorphism. Structured exception handling provides a global error handler and eliminates
spaghetti code.

2.3 XML Web Services

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.

2.3.1 Mobile Applications

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.

2.3.2 COM Interoperability


You can maintain your existing code without the need to recode. COM
interoperability enables you to leverage your existing code assets and offers seamless bi-
directional communication between Visual Basic 6.0 and Visual Basic .NET applications.

23
`

2.3.3 Reuse Existing Investments


You can reuse all your existing ActiveX Controls. Windows Forms in Visual
Basic .NET 2003 provide a robust container for existing ActiveX controls.

In addition, full support for existing ADO code and data binding enable a smooth transition to
Visual Basic .NET 2003.

2.3.4 Upgrade Wizard


You upgrade your code to receive all of the benefits of Visual Basic .NET 2003. The Visual
Basic .NET Upgrade Wizard, available in Visual Basic .NET 2003 Standard Edition, and higher,
upgrades up to 95 percent of existing Visual Basic code and forms to Visual Basic .NET with
new support for Web classes and User Controls.

24
`

25
`

3.0 TESTING OBJECTIVES

Testing is a process of executing a program with an intense of finding an error. A


test is on that has a high probability or finding an undiscovered errors. A successful test is
that uncovers an undiscovered errors.

3.1 TYPE OF TESTING DONE:

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.

3.1.1 UNIT TESTING:

The modules of the system are tested as an individual in unit testing; each unit has
definite input and output parameters.

3.1.2 INTEGRATION TESTING:

In the system testing, the system is tested as a whole intercommunication, among


the individual units and functions of the complete system are tested.

3.1.3 SYSTEM TESTING:

In the system testing, the system is tested as a whole intercommunication, among


the individual units and functions of the complete system are tested.

3.1.4 DESTRUCTION TESTING:

In this type of testing, the application is tested until it does something. A is not
suppose to do.

3.1.5 WINDOWS DESIGNING TEST:

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
`

3.1.6 FUNCTION TESTING:

This testing method ensures that the nuts and bolts functions of the system are
actually tested.

3.1.7 INTEGRATION TESTING:

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.

3.1.8 PERFORMANCE TESTING:

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

Implementation is the stage where the theoretical is converted into a working


system. This is the processing converting a new or a revised system into an operational
one of the implementation consists of

 Testing the developed system with sampled data.


 Detection and correction of errors.
 Making necessary charges in the system.
 Checking of reports with that of the existing system.
 Training of software and hardware utilities.
 Installation of software and hardware utilities

27
`

28
`

4.0 IMPLEMENTATION ON CLIENT MACHINE(Graphically)

4.1 User Password

In order for remote desktop to work, you have to set a password on your user account. Follow
these steps to set a password.

1. Go to Start then to My Computer (or go to your desktop and go to My Computer)


2. Go to Control Panel
3. Go to User Accounts
4. Click on your user account
5. Go to Create a Password
6. Fill everything out and hit Create Password

4.2 Enabling Remote Desktop Connection (on the host)

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”

4.3 Getting your IP address

You now have to get your ip address.

4.3.1 Connecting to the host machine from another machine

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.

• You can access your documents from anywhere.

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

• You can’t play games with it.


• Images lag the connection.
• In order to start the server you have to log into your account, meaning if you’re on
vacation and your computer locks up, you’ll have to have someone else reboot the
computer and log in with your password. But this problem can be fixed by modifying a
DLL file and adding a registry value. And up to 2 more computers can be connected
remotely at the same time.

4.5 SCREEN SHOTS

System info:

31
`

4.6 Explorer:

.4.7Service form:

32
`

4.8 Process form:

4.9 Bitmap Functions

Win32 function Description .NET Framework API


AlphaBlend Displays a System.Drawing.Graphics.DrawImage

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

Win32 function Description .NET Framework API

34
`

CreateBrushIndirect Creates a brush Any of the following:


with a specified System.Drawing.Brushes
style, color, and System.Drawing.SolidBrush
pattern. System.Drawing.TextureBrush
System.Drawing.Drawing2D.HatchBrush
System.Drawing.Drawing2D.LinearGradientBrush
System.Drawing.Drawing2D.PathGradientBrush
CreateHatchBrush Creates a brush System.Drawing.Drawing2D.HatchBrush
with a hatch constructor
pattern and color.
CreatePatternBrush Creates a brush System.Drawing.TextureBrush constructor
with a bitmap
pattern.
CreateSolidBrush Creates a brush System.Drawing.SolidBrush constructor
with a solid color.
GetSysColorBrush Gets a handle for System.Drawing.Brushes class
a brush that
corresponds to a
color index.
5.0 IMPLEMENTATION ON CLIENT MACHINES:

1.Go to Run Command


Services.msc
*Network Sharing
*COM+EVENT
*COM+SYSTEM APPLICATION
* Remote Access System Manager
*Remote Acess Connection Manager
*Remote Procedure Call
*Remote Registry
*Remote Storage
*Telnet
*Windows Firewall
*Windows Management Instrumentation
* Windows Management Instrumentation Driver
Properties
Assign it as AUTOMATIC
2.Go to Run Command

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

Graphical Representation Of Implementing Client Machine

Run Command

Services.msc:

36
`

Network Sharing:
COM+EVENT

37
`

COM+SYSTEM APPLICATION

Remote Access Connection Manager:

Remote Desktop Help Session

38
`

Telnet:

Windows Management Instrumentation:

39
`

2. Go to Run Command:

40
`

Network access:

41
`

My Computer
*Manage

42
`

WMI Program:

WMI Services:

43
`

Assign Verbose:

Allow all user:

44
`

3.Firewall:

Off the Fire wall Settings:


45
`

Exception:
Check all the boxes

Password:

46
`

Set Password:

47
`

6.0 Source code:


48
`

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
`

public string stringUserName;


}
public class ProcessesInfo
{
private structProcessInfo _value;
/// <summary>
/// property Value
/// </summary>
public structProcessInfo Value
{
get {return _value;}
set {_value = value;}
}
}
/// <summary>
/// Summary description for Dictionary.
/// </summary>
public class ProcessesDictionary : NameObjectCollectionBase
{
/// <summary>
/// Clear dictionary
/// </summary>
public void Clear()
{
BaseClear();
}
/// <summary>
/// Add item to dictionary
/// </summary>
/// <param name="name"></param>
/// <param name="processObj"></param>

51
`

public void Add(string name, ProcessesInfo processObj)


{
BaseAdd(name, processObj);
}
/// <summary>
/// Remove item from dictionary
/// </summary>
/// <param name="name"></param>
public void Remove(string name)
{
BaseRemove(name);
}
/// <summary>
/// Index remove item from dictionary
/// </summary>
/// <param name="index"></param>
public void RemoveAt(int index)
{
BaseRemoveAt(index);
}
/// <summary>
/// ProcessesInfo property by index
/// </summary>
public ProcessesInfo this[int index]
{
get {return (ProcessesInfo)BaseGet(index);}
set {BaseSet(index, value);}
}
/// <summary>
/// processInfo property by key
/// </summary>

52
`

public ProcessesInfo this[string name]


{
get {return (ProcessesInfo)BaseGet(name);}
set {BaseSet(name, value);}
}}}
3. Process performance dictionary:

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
`

public void RemoveAt(int index)


{
BaseRemoveAt(index);
}
/// <summary>
/// Access ProcessPerf item by index
/// </summary>
public ProcessPerf this[int index]
{
get {return (ProcessPerf)BaseGet(index);}
set {BaseSet(index, value);}
}
/// <summary>
/// Access ProcessPerf item by key
/// </summary>
public ProcessPerf this[string name]
{
get {return (ProcessPerf)BaseGet(name);}
set {BaseSet(name, value);}
}
}
}
Services .cs

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 );
}

/// </summary> private void InitializeComponent()


{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Srvices));
this.panel1 = new System.Windows.Forms.Panel();
this.buttonRefresh = new System.Windows.Forms.Button();
this.radioRemoteMachine = new System.Windows.Forms.RadioButton();
this.textPassword = new System.Windows.Forms.TextBox();
this.textUserID = new System.Windows.Forms.TextBox();
this.labelPassword = new System.Windows.Forms.Label();
this.labelUserID = new System.Windows.Forms.Label();
this.labelIP = new System.Windows.Forms.Label();
this.textIP = new System.Windows.Forms.TextBox();
this.radioMachine = new System.Windows.Forms.RadioButton();
this.listViewServices = new System.Windows.Forms.ListView();

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();

//create list item


ListViewItem lvItem = new ListViewItem(lvData,0);
listViewServices.Items.Add(lvItem);
}
}
catch (Exception e)
{
MessageBox.Show("Error: " + e);
}

//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;

if (rbClicked.Text == "&Current Machine")


booleanFlag = false;

//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
`

/// <param name="e"></param>


private void buttonRefresh_Click(object sender, System.EventArgs e)
{
//call refresh function
this.Refresh();
}

/// <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;

//Set up a handler for the asynchronous callback


ManagementOperationObserver observer = new
ManagementOperationObserver();
completionHandler.MyHandler completionHandlerObj = new
completionHandler.MyHandler();
observer.ObjectReady += new
ObjectReadyEventHandler(completionHandlerObj.Done);

//get specific service object

64
`

queryCollection = getServiceCollection("Select * from Win32_Service


Where Name = '" + ServiceName + "'");

//Status
updateStatus("Starting/Stopping service...");

foreach ( ManagementObject mo in queryCollection)


{
//start or stop service
mo.InvokeMethod(observer, ServiceAction, null);
}

//wait until invoke method is complete or 5 sec timeout


int intCount = 0;
while (!completionHandlerObj.IsComplete)
{
if (intCount > 10)
{
MessageBox.Show("Terminate process timed out.",
"Terminate Process Status");
break;
}
//wait 1/2 sec.
System.Threading.Thread.Sleep(500);

//increment counter
intCount++;
}

//see if call was successful.

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";

MessageBox.Show("Failed to " + stringAction + " service " +


ServiceName + ".", "Start/Stop Service Failure");
}

//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 = "";

//Connect to the remote computer


ConnectionOptions co = new ConnectionOptions();

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;
}

//get user and password


if (textUserID.Text.Trim().Length > 0)
{
co.Username = textUserID.Text;
co.Password = textPassword.Text;
}

//Point to machine
System.Management.ManagementScope ms = new
System.Management.ManagementScope("\\\\" + stringMachineName + "\\root\\cimv2", co);

//Status
updateStatus("Getting Services Information");

//Query remote computer across the connection


oq = new System.Management.ObjectQuery(stringQuery);
query = new ManagementObjectSearcher(ms,oq);

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

You might also like