Yesterday I atteneded this webcast that was dedicated for the new features in Visual Studio 2008.
Vishal R. Joshi presented the following topics:
Cascade Style Sheets Css.
The New ListView control.
LINQ to SQL
You can watch this webcast again here
A couple of days ago, Scott Guathrie gave a brief introduction to the new version of silverlight 2
, he discussed the new features, and provided a couple of tutorials.
There are a lot of resources about Windows Card Space on the Internet.
I collected some of those good resources: articles, books, blogs, forms, samples and videos on a single article on ASP.NET Wiki article.
Microsoft just release this new website for all of the Visual Studio extensions categories, check it out http://visualstudiogallery.com/
Almost all modern peripheral devices use the USB port as an interface to connect to the pc. This post will show how to detect an insertion or removal of a device in a USB port.
I will use the Windows Management Instrumentation (WMI) which is a component of the Windows operating system that allows you to programmatically access management information in an enterprise environment.
First we should add the System.Management name space as a reference to our project
The add: using System.Management;
When a USB device is inserted a 'Win32_USBControllerdevice' record is added to the operating system's metabase and when the device is removed, that record will be deleted.
So we have to add two events to the same record and these events are "__InstanceCreationEvent" for insertion and "__InstanceDeletionEvent" for removal.
The following method "AddHandler()" adds an event handler that is fired when a USB device is inserted.
//used to subscribes to temporary event notifications based on a specified event query.
WqlEventQuery q;// Represents a WMI event query in WQL format (Windows Query Language)
ManagementScope scope = new ManagementScope("root\\CIMV2");
// Represents a scope (namespace) for management operations.
scope.Options.EnablePrivileges = true;
q = new WqlEventQuery();
q.EventClassName = "__InstanceCreationEvent";
q.WithinInterval = new TimeSpan(0, 0, 3);
q.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'";
w = new ManagementEventWatcher(scope, q);
//adds event handler that’s is fired when the insertion event occurs
w.EventArrived += new EventArrivedEventHandler(USBInseted);
w.Start();//run the watcher
catch (Exception e)
if (w != null)
FileStream FS = new FileStream(@”C:\USB_Log.txt”, FileMode.Append);
StreamWriter SW = new StreamWriter(FS);
public void USBInseted(object sender, EventArgs e)
SW.WriteLine("USB device is inserted at " + DateTime.Now.ToString());
private void Form1_Load(object sender, EventArgs e)
Important note: you should stop the watcher before exiting the application or else an excption is thrown
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
if (w != null)
Now to add another handler for that fire when the USB device is removed all you have to do is just to set the EventClassName property of the WqlEventQuery object to “__InstanceDeletionEvent”.
Tody I jus t got graduated from collage, I am now a computer systems engineer.
I'm so excited that now I will have enough time to get back to work with .NET technologies