登录
记住用户名密码
实现原理:
1.检查是否是U盘
2.查检U盘的卷标
3.通过VolumeLable的返回值对比判断是否你加密的U盘(卷标要定义好)
function CheckUsbDisk(FLable:string):Boolean; //检验是否是USB优盘 var Drive: Integer; DriveLetter: Char; begin Result :=false; for Drive := 2 to 25 do begin DriveLetter := Chr(Drive + ord('A')); if GetDrivetype(PChar(DriveLetter+':\'))= DRIVE_REMOVABLE then begin if VolumeID(DriveLetter)=FLable then begin Result :=true; exit; end; end; end; end;
function VolumeLable(DriveChar: Char): string; //检验USB优盘的卷标 var OldErrorMode: Integer; NotUsed, VolFlags: DWORD; Buf: array [0..MAX_PATH] of Char; begin OldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS); try Buf[0] := #$00; if GetVolumeInformation(PChar(DriveChar + ':\'), Buf, DWORD(sizeof(Buf)), nil, NotUsed, VolFlags, nil, 0) then SetString(Result, Buf, StrLen(Buf)) else Result := ''; if DriveChar < 'a' then Result := AnsiUpperCaseFileName(Result) else Result := AnsiLowerCaseFileName(Result); Result := Format('%s',[Result]); finally SetErrorMode(OldErrorMode); end; end;
目前有 0 条留言 其中:访客:0 条, 博主:0 条