foreach (System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives()) { if ((drive.DriveType == System.IO.DriveType.Removable)) { } }
[DllImport("user32.dll", SetLastError = true)] static extern bool LockWorkStation(); bool result = LockWorkStation(); if (result == false) { throw new Win32Exception(Marshal.GetLastWin32Error()); }
foreach (System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives()) { if ((drive.DriveType == System.IO.DriveType.Removable)) { label1.Text = label1.Text + " " + drive.Name; string resumeFile = drive.Name + @"locker\locker.txt"; if (File.Exists(resumeFile)) { System.IO.StreamReader myFile = new System.IO.StreamReader(resumeFile); myString = myString + " "+myFile.ReadToEnd(); myFile.Close(); } } } if (myString.Contains("91999")) { // do nothing } else { // lock computer }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)