h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Status of Service installed using C#

use this method for retrieving Service Installed or Not:
private static bool IsSerInstalled(string serviceName)
{
// get list of Windows services
System.ServiceProcess.ServiceController[] ser = ServiceController.GetServices();
// try to find service name
foreach (ServiceController service in ser)
{
if (service.ServiceName == serviceName)
return true;
}
return false;
}
Call this function/Method where do you want?
if (IsSerInstalled("AdobeFlashPlayerUpdateSvc"))
{
MessageBox.Show("Yes");
}
else
{
MessageBox.Show("No");
}
Result: "yes"

List of Windows Service using C#

Introduction A long running executable that's designed to work without user interaction.
It can be configured to start when the system boots and they can be run without any users logged into the system.
Get list of installed windows services ServiceContro­ller.GetServi­ces: get list of all services.
ServiceContro­ller.GetDevices: get list of driver services.
How to use in C#.net? · Create Project.
· Add Datagridview on the Form.
· Add “System.ServiceProcesss” using AddReference.
Add namespace:
using System.ServiceProcess;
Add Method:
void listofservice()
{
// get list of Windows services
System.ServiceProcess.ServiceController[] services = ServiceController.GetServices();
DataTable dt = new DataTable(); //add DataTable
DataColumn dc = dt.Columns.Add("ServiceName");
DataColumn dc1 = dt.Columns.Add("Display Service Name");
dc.Caption = "Service Name"; // set the caption
dc1.Caption = "Dispaly Service Name"; // set the caption
// try to find service name
foreach (ServiceController service in services)
{
dt.Rows.Add(service.ServiceName, service.Status);//add DataRow to DataTable by values
}
dataGridView1.DataSource = dt;
}
private void Form1_Load(object sender, EventArgs e)
{
listofservice();
}

Software Design Pattern

Introduction:
· A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
· Design patterns are recurring solutions to software design problems.
· Patterns are about design and interaction of objects, as well as providing a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges.
Use of Design Pattern: A design pattern helps you to find tested proven design paradigm to build a solid foundation for your project. So, if you follow design pattern you can easily prevent major issues to come while building your actual project. Moreover design pattern also helps the other architects to understand your code easily.
History of Design Pattern: Types of Design Pattern: · Creational patterns.
· Structural patterns.
· Behavioral patterns.
· Concurrency patterns.
Now, I am going to discuss few examples of patterns. They are
· Singleton Design Pattern.
· Factory Design Pattern.
· Factory Method Design Pattern.
· Abstract Factory Design Pattern.
· Builder Design Pattern.
· Adapter Design Pattern.
· Bridge Design Pattern.
· Composite Design Pattern.
· Flyweight Design Pattern. Singleton Design Pattern
Singleton pattern creates a class which can have a single object throughout the application,
Factory Pattern: A Factory is actually a creator of object which has common interface.
Factory Method Design Pattern: It creates the object of the class through interfaces but on the other hand, it also lets the subclass to decide which class to be instantiated.
Abstract Factory Design Pattern: It provides Factory interfaces for creating a family of related classes.
Builder Design Pattern: This pattern creates object based on the Interface, but also lets the subclass decide which class to instantiate.
Adapter Design Pattern: Adapter pattern actually makes two classes compatible.
Bridge Design Pattern: Bridge pattern compose objects in tree structure. It decouples abstraction from implementation.
Composite Design Pattern: Composite pattern treats components as a composition of one or more elements.
Flyweight Design Pattern: Flyweight allows you to share bulky data which are common to each object.