How restrict an application to run only from a known USB flash drive?

混江龙づ霸主 提交于 2019-12-04 10:19:23
David

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?

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();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!