Geekpedia Programming Tutorials






Win32_DeviceChangeEvent And Prohibit Access USB

On Friday, August 28th 2009 at 11:58 AM
By Tolga Ongunsu
I generated the code below with wmi code creator. It listens the device
changings. I want to prohibit the usb access or cdrom access in my computer
section. Is there any ideas about it like sddl ...???

Thanks in advance.

try
{
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM Win32_DeviceChangeEvent");

ManagementEventWatcher watcher = new
ManagementEventWatcher(query);
Console.WriteLine("Waiting for an event...");

ManagementBaseObject eventObj = watcher.WaitForNextEvent();

Console.WriteLine("{0} event occurred.",
eventObj["__CLASS"]);

// Cancel the event subscription
watcher.Stop();
return;
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to receive
an event: " + err.Message);
}
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons