Using WMI interface POS for dotnet

G

Guest

There are 4 main classes in
1. ServiceObject
2. PosDevice
3. LogicalDevice
4. DeviceProperty

I am going to develop application for managing devicess. Using
PosDevice class i get the all the deviess in the system and now i need to
get the Device properties for each device. Please help me to do this. Is
there way to get the propertied for each dvicesss using devices?
 
P

Pascal Bouchard

Using WMI, you will be able to get ManagementObject instances (let's say
"mo"); when pointing to the right "mo", you can get properties with the
following syntax :

ManagementClass mc = new
ManagementClass("root\\MicrosoftPointOfService","ServiceObject",null);
int count = 0;

foreach ( ManagementObject mo in mc.GetInstances() )
{
this.cb_so.Items.Add(mo.GetPropertyValue("Name")); // Add Service
Object's name to combobox
count++;
}

or call a method this way :

ManagementObject mo = ....
POSDevice posdev = new POSDevice(mo);
posdev.SetPath(tb_path.Text);

Do not hesitate for more questions.
 
G

Guest

Hi Pascal,

I have a problem relating to the same.
I want to select (or quarry) a particular device to get its properties.
How can I do this using WMI?
I tried using the "POSDevice.POSDeviceCollection" but no luck.
How can I finf some good documantation on this?

Thanks for the support.
Kauhsalya
 
P

Pascal Bouchard

Here is a code sample on how to make a query for a perticular POSDevice :

private void RefreshPosDeviceCb() // ComboBox refresh
{
string sel;
IsValidPosDevice = false;

sel = "select * from PosDevice where SoName=\"";
sel += this.cb_so.SelectedItem; // per example "ExampleMsr"
sel += "\"";

this.statusBar1.Text = "Refreshing Pos Device List";
this.cb_posdev.Items.Clear();

ManagementObjectSearcher mos = new
ManagementObjectSearcher("root\\MicrosoftPointOfService",sel,null);
ManagementObjectCollection moc = mos.Get();

int count = 0;

foreach ( ManagementObject mo in moc )
{
this.cb_posdev.Items.Add(mo);
count++;
}

this.statusBar1.Text = count + " Pos Device(s) Found";
}

.... Then, with the code example i already sent, you can get POSDevice
properties using the autocompletion with your POSDevice object, it works;
here is the example again :

ManagementObject mo = ....
POSDevice posdev = new POSDevice(mo);
MessageBox.Show(posdev.SoName);
MessageBox.Show(posdev.Enabled.ToString());
posdev.SetPath(tb_path.Text);

.... if you are interested on properties, methods and qualifiers of you
POSDevices or ServiceObjects or... you can call, from the command prompt
"wbemtest.exe".

If i remember, i found my documentation at MSDN.
http://msdn.microsoft.com/library/d...ry/en-us/cpref/html/frlrfsystemmanagement.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top