| 
				 3.2  U盘卸载与授权的判定 
上文中获取了U盘的插入及U盘的盘符和序列号,从而作为我们判断U盘是否合法的依据。本过程首先对U盘进行授权判定,对不合法的U盘卸载并保存使用时间到日志文件中。 
//定时器处理过程用于卸载、放行U盘的判定 
procedure TForm1.Timer1Timer(Sender: TObject);    
var 
MyDate:TDateTime;     
sj:string;  
count,i:smallint; 
ysq:boolean; 
temp:dword; 
begin 
Timer1.Enabled:=false; 
//表示此次卸载是本程序自己完成的 
SelfDisMount:=true;   
ysq:=false;  //授权布尔变量 
//已授权U盘序列号总数 
count:=listbox1.Items.Count; 
//遍历listbox控件项目是否该U盘已授权。 
for i:=0 to count-1 do 
begin 
   temp:=strtoint(listbox1.Items.Strings[i]); 
   if temp=UsbId then //判断U盘序列号 
      begin 
         ysq:=true; //该U盘已授权 
         break; 
      end; 
  end; 
if ysq then   //已授权不卸载该U盘 
begin 
  SelfDisMount:=false; 
  DisMountCmdOk:=false; 
  exit; 
end; 			
				 |