问题
I need an application to run only from a specific USB flash drive. I made some test with the WMI Win32_Diskdrive class and the PNPdeviceID property. It is a very good idea to enroll the application into a license server (web services) with this data, but I'm searching for a second method to reenforce this one in order to make the process harder to break.
I was thinking to create a second little hidden partition in the drive and locate in it as a name the serial obteined by the PNPdeviceID or other information. Any other idea, method or suggestion is accepted.
Thanks in advance.
EDIT: I already know a unique ID from the USB flash drive and the application can check if the Interfacetype property is "USB". I´m enrolling the application with a hash of the PNPDeviceID in a web-services suported licence manager. I'm searching for an additional second validation method.
回答1:
You can check the volume serial number, which will catch casual copying to a newly formatted volume, but it won't detect full byte-exact volume copies.
To protect software by accessing harddisk serial no
Any faster method to get Volume Serial number?
回答2:
You can check the type of drive from which the program is running :
string path = Process.GetCurrentProcess().MainModule.FileName;
FileInfo fileInfo = new FileInfo(path);
string driveRoot = fileInfo.Directory.Root.Name;
DriveInfo driveInfo = new DriveInfo(driveRoot);
if (driveInfo.DriveType != DriveType.Removable)
{
MessageBox.Show("Must run from removable drive");
Application.Exit();
}
来源:https://stackoverflow.com/questions/1303026/how-restrict-an-application-to-run-only-from-a-known-usb-flash-drive