Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.text;using system.windows.forms;using microsoft.win32;namespace usbforensic1{public partial class Form1: Form {public Form1 () {InitializeComponent (); } private void Button1_Click (object sender, EventArgs e) {RegistryKey usbconnkey; Usbconnkey = Registry.LocalMachine.OpenSubKey (@ "System\currentcontrolset\enum\usbstor", false); foreach (String sub1 in Usbconnkey.getsubkeynames ()) {RegistryKey Sub1key = USBCONNKEY.OPENSUBK EY (Sub1, false); foreach (String sub2 in Sub1key. Getsubkeynames ()) {try {RegistryKey Sub2key = Sub1key. OpenSubKey (Sub2, false); if (Sub2key. GetValue ("Service", ""). Equals ("Disk")) { String Path = "Usbstor" + "\ \" + sub1 + "\ \" + sub2; String Name = (string) Sub2key. GetValue ("FriendlyName", "" "); Richtextbox1.appendtext ("USB name" + name + "\ r \ n"); Richtextbox1.appendtext ("UID Tag" + sub2 + "\ r \ n"); Richtextbox1.appendtext ("path information" + Path + "\r\n\r\n"); }} catch (Exception msg) {Messagebox.sho W (Msg. Message); } } } } }}
C # read computer plugged into USB history