473,545 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#.Net: WMI Provider,Implem enting Instance operations

3 New Member
Hi,
I ve saw a sample instance provider and have done a service which wil just display wat i have entered in ma service code.. Now i want to Enumerate, Create, Get, Modify operations. Can anyone plz help me out..

I have included ma code in this.. plz tel how to implement those operations..

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Diagnost ics;
using System.ServiceP rocess;
using System.Manageme nt.Instrumentat ion;
using Tel_Dir_Provide r;

namespace Tel_Dir
{
public class Service1 : System.ServiceP rocess.ServiceB ase
{
// this parameter will be exposed by the provider.
private string S_name ="AMI-US";
private long S_ph_no = 7702552663;
private string S_address ="USA";

private System.Componen tModel.Containe r components = null;
Tel_Dir_Provide r.Tel_Dir S_Tel_Dir_Provi der;

public Service1()
{
// This call is required by the Windows.Forms Component Designer.
InitializeCompo nent();
Set_Tel_Dir();
}

// The main entry point for the process
static void Main()
{
System.ServiceP rocess.ServiceB ase[] ServicesToRun;

// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = new System.ServiceP rocess.ServiceB ase[] {new Service1(), new MySecondUserSer vice()};
//
ServicesToRun = new System.ServiceP rocess.ServiceB ase[] { new Service1() };

System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
components = new System.Componen tModel.Containe r();
this.ServiceNam e = "Tel_Dir";
}

private void Set_Tel_Dir()
{
//Create provider instance
S_Tel_Dir_Provi der = new Tel_Dir_Provide r.Tel_Dir();
//set some values
S_Tel_Dir_Provi der.S_Name = S_name;
S_Tel_Dir_Provi der.S_Address = S_address;
S_Tel_Dir_Provi der.S_Ph_No = S_ph_no;
//Makes an instance visible through management instrumentation .
Instrumentation .Publish(S_Tel_ Dir_Provider);
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
protected override void OnStart(string[] args)
{
Tel_Dir_Synopsi sEvent pje = new Tel_Dir_Synopsi sEvent();
pje.ServiceName = "Telephone Directory";
pje.Method = "Set";
// This will raise the a Tel_Dir_Synopsi sEvent management event.
Instrumentation .Fire(pje);
}


protected override void OnStop()
{
Tel_Dir_Details Event ple = new Tel_Dir_Details Event();
ple.Developer = "Sridhar.G & Prakash.S";
ple.ProjectLead s = "Arun.V & Chitrak";
// This will raise the a Tel_Dir_Details Event management event.
Instrumentation .Fire(ple);
}
}
}

My class file is as follows..

using System;
using System.Manageme nt;
using System.Configur ation.Install;
using System.Manageme nt.Instrumentat ion;


// Define unique namespace.
[assembly:Instru mented("root/CimV2")]

//Installs an instrumented assembly (InstallUtil.ex e).
[System.Componen tModel.RunInsta ller(true)]
public class InstanceInstall er : DefaultManageme ntProjectInstal ler {}



namespace Tel_Dir_Provide r
{

[Instrumentation Class(Instrumen tationType.Even t)]
public class Tel_Dir_Details Event
{
public string Developer;
public string ProjectLeads;
}

[Instrumentation Class(Instrumen tationType.Even t)]
public class Tel_Dir_Synopsi sEvent
{
public string ServiceName;
public string Method;
}

/// define the Telephone Directory provider class.
[Instrumentation Class(Instrumen tationType.Inst ance)]
public class Tel_Dir
{
private string name;
private long phone_no;
private string address;

public Tel_Dir()
{
name="";
phone_no = 0 ;
address="";
}

public string S_Name
{
get
{
return name;
}

set
{
name = value;
}
}

public string S_Address
{
get
{
return address;
}

set
{
address = value;

}
}

public long S_Ph_No
{
get
{
return phone_no;
}

set
{
phone_no = value;

}
}
}
}


Here i have entered the name, phone num and address so it is getting displayed when i start the server.. But i wanna know how to implement Create, Get, Modify etc operations for instance provider..

Regards,
Sridhar
Dec 5 '07 #1
0 1578

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2520
by: Saga | last post by:
Hi all, I just read the thread by the same name posted on Jun 15, 9:45 AM, but I am looking at it from a different point of view. I came across this question in terms of functionality. Are VB and C# (.NET) really functionally equivalent? I had read that although they are very similar, C# does extend functionality further than VB.NET;...
6
1503
by: Paul Colton | last post by:
I want to pre-process some of my pages using some custom code, then output the ASP.NET page so the regular ASP.NET handler takes care of it. I'd like for page caching, etc. to work as normal. What's the best approach? -Paul
5
3890
by: Davie | last post by:
I am implementing a Custom Provider for ASP.NET 2.0 membership. When I come to write the public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { throw new Exception("The method...
2
1498
by: Doug | last post by:
Hi, I wanted to start a general discussion more for getting some thoughts on what other people think/practice out there just to see how far (if at all) I'm off base on my own thoughts. My primary experience is developing applications using VB or DotNet. I have some sql skills but they are limited. In a previous company our concept on...
0
3645
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. · When was the first version of .NET released?...
0
2554
by: shamirza | last post by:
ADO.Net Making the Connection: Accessing Your Database using ADO.NET Data Access Namespaces Within the .NET framework class library (FCL) version 1.1, there are five third-level namespaces that provide access to an underlying database. These are System.Data.SqlClient, System.Data.SqlServerCE, System.Data.OracleClient, System.Data.OleDb, and...
0
3822
by: shamirza | last post by:
· What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested for the first time versus when the form is posted (sent to the server), which allows you to program accordingly. · What are user controls and...
1
2285
by: ssnsridhar | last post by:
C#.Net:i need to know about how to create a wmi instance provider in c#.Net implementing instance operations like get create delete enumerate set instances. Can anyone please help me.
8
2629
by: nickooooola | last post by:
Hello to all I'm about to write a simulator for a microcontroller in python (why python? because I love it!!!) but I have a problem. The registry of this processor are all 8 bit long (and 10 bit for some other strange register) and I need to simulate the fixed point behaviour of the register, and to access the single bit.
0
7416
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7932
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7442
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7776
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5347
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
729
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.