![]() |
|
#5
|
|||
|
|||
![]() А также можешь использовать проверку на наличие устройства в USB:
Код:
function IsUSBDevice(DevInst: DWORD): boolean; function CompareMem(p1, p2: Pointer; len: DWORD): boolean; var i: DWORD; begin result := false; if len = 0 then exit; for i := 0 to len-1 do if PByte(DWORD(p1) + i)^ <> PByte(DWORD(p2) + i)^ then exit; result := true; end; var IDLen: DWORD; ID : PChar; err : TIniFile; begin try result := false; if (CM_Get_Device_ID_Size(@IDLen, DevInst, 0) <> 0) or (IDLen = 0) then exit; inc(IDLen); ID := GetMemory(IDLen); if ID = nil then exit; if (CM_Get_Device_IDA(DevInst, ID, IDLen, 0) <> 0) or (not CompareMem(ID, PChar('USBSTOR'), 7)) then begin FreeMemory(ID); exit; end; FreeMemory(ID); result := true; except err:=TIniFile.Create('C:\Locomotiv\Config\Errors.ini'); err.WriteString('UnknownErrors', 'IsUSBDevice/'+DateToStr(Date)+'/'+TimeToStr(Time), 'Ошибка в функции'); err.Free; end; end; |