掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
USBメモリかどうかを識別するには? (ID:36415)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
時間経ってるからもう解決ずみかな? ちょっとインチキっぽいけど、ドライブ文字から調べるならこんなのはどうでしょう。 function IsUsbDrive(ADrv: Char): Boolean; const S = ['A'..'Z']; MAX_DEVS = $FFFF; MAX_DEV = $0400; var strDrv: String; strDevNam : String; desDevName :array[0..MAX_DEV -1] of Char; dosDevices :array[0..MAX_DEVS -1] of Char; iIdx, iDosCnt, iPosCnt :Integer; pHedPos :PChar; begin Result := false; // A〜Z以外は処理終了 if not CharInSet(ADrv,S) then Exit; strDrv := ADrv + ':'; if QueryDosDevice(PChar(strDrv), @desDevName, MAX_DEV) <= 0 then Exit; strDevNam := desDevName; iDosCnt := QueryDosDevice(nil, @dosDevices, MAX_DEVS); if iDosCnt > 0 then begin iPosCnt := 0; while (iPosCnt < iDosCnt) do begin pHedPos := @dosDevices[iPosCnt]; if ('STORAGE' = copy(pHedPos,1,7)) and (Pos('USBSTOR', pHedPos) > 0) then begin if QueryDosDevice(pHedPos, @desDevName, MAX_DEV) > 0 then begin if (desDevName = strDevNam ) then begin Result := true; Exit; end; end; end; iIdx := 0; while (iPosCnt < iDosCnt) and (pHedPos[iIdx] <> #0) do begin Inc(iIdx); Inc(iPosCnt); end; Inc(iPosCnt); end; end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.