if disksize(1)=-1 表示软驱A中没有软盘 

解决方案 »

  1.   

    该段代码为检测驱动器是否就绪,其中A代表软驱function DiskInDrive(Drive: Char): Boolean;
    var ErrorMode: word;
    begin
    { make it upper case }
    if Drive in ['a'..'z'] then Dec(Drive, $20);
    { make sure it's a letter }
    if not (Drive in ['A'..'Z']) then
    raise EConvertError.Create('Not a valid drive ID');
    { turn off critical errors }
    ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
    try
    { drive 1 = a, 2 = b, 3 = c, etc. }
    if DiskSize(Ord(Drive) - $40) = -1 then
    Result := Falseelse
    Result := True;
    finally
    { restore old error mode }
    SetErrorMode(ErrorMode);
    end;
    end;
      

  2.   

    我一直用这段代码://返回true软驱里是否有软盘,false没有
    function TestFDriver:Boolean;
    var
      pres:UINT;
      pvol:array [0..128] of char;
      vols,maxcl,fsf:DWORD;
    begin
      pres := SetErrorMode(SEM_FAILCRITICALERRORS);
      try
        maxcl := 0;
        fsf := 0;
        Result := GetVolumeInformation('a:\',pvol,sizeof(pvol)-1,@vols,maxcl,fsf,nil,0)
      finally
        SetErrorMode(pres);
      end;
    end;
      

  3.   

    if DiskFree(1) = -1 then  //软驱A中没有软盘