在DELHPI编程过程中用什么样的方法判断是否放了光盘、软盘。

解决方案 »

  1.   

    尝试访问就Ok了1)GetVolumeInformation等查询方法2)访问根目录方法http://lysoft.7u7.net
      

  2.   

    procedure Tform1.WMDEVICECHANGE(var msgx :Tmessage);constDBT_DEVICEARRIVAL=$8000;DBT_DEVICEREMOVECOMPLETE=$8004;begininherited;case msgx.WParam ofDBT_DEVICEARRIVAL:Caption :='有了!';DBT_DEVICEREMOVECOMPLETE:Caption :='取走了';end;end;
      

  3.   

    //获取光盘或硬盘的卷标名和序列号
    procedure GetDiskInfo(const Drv:string;var Name:string;Var Sn:integer);
    var
      VolumeName    : array[0..255] of char;
      MaximumComponentLength : DWORD;
      FileSystemFlags : DWORD;
      Serial:DWord;
      s:string;
    begin
      s:=Drv;
      if s[Length(s)] =':' then s := s + '\';
      GetVolumeInformation(pChar(s),
                           VolumeName,
                           256,
                           @serial,
                           MaximumComponentLength,
                           FileSystemFlags,
                           nil,
                           0);
      name:=volumename;
      sn:=integer(Serial);
    end;var
    s:string;
    n:integer;
    ....
    getdiskinfo('G:\',s,n);
    if n<>0 then showmessage(s);
      

  4.   

    这个问题,可以用API函数来实现的,你找个字典查查吧,我以前在相关的资料找到过