procedure TFrm_Main.GetDisks;
var
  str:string;
  Drivers:Integer;
  driver:char;
  i,temp,disksizee:integer;
  d1,d2,d3,d4: DWORD;
  J:Integer;
  ListItem: TListItem;
begin
  Drivers:=GetLogicalDrives;
  temp:=(1 and Drivers);
  for i:=0 to 26 do
  begin
    if temp=1 then
    begin
      driver:=char(i+integer('A'));
      str:=driver+':';
      if (driver<>'') and (getdrivetype(PChar(str))<>drive_cdrom) and (getdrivetype(PChar(str))<>DRIVE_REMOVABLE) then
      begin
        GetDiskFreeSpace(PChar(str),d1,d2,d3,d4);
        ListItem := MainList.Items.Add;
        ListItem.ImageIndex:=0;
        with ListItem do
        begin
          Caption := str;
          J:=SubItems.Add(Format('总空间: %f GB',[d4/1024/1024/1024*d2*d1])+Format('剩余空间: %f GB',[d3/1024/1024/1024*d2*d1]));
          J:=SubItems.Add(Format('剩余空间: %f GB',[d3/1024/1024/1024*d2*d1]));
          J:=SubItems.Add(datetimetostr(Now()));
          MainList.Items.EndUpdate;
        end;
      end;
    end;
    drivers:=(drivers shr 1);
    temp:=(1 and Drivers);
  end;
end;这是我的代码!总共提示有两个错误
1:[Error] Frm_Main_U.pas(1129): Invalid typecast
2:[Error] Frm_Main_U.pas(1131): Statement expected, but expression of type 'LongBool' found谁能帮解决啊!!!  在线等啊

解决方案 »

  1.   

    嗯,提示代码有问题,是不是我的DELPHI有问题啊?有很多这种错误!!
    比如说   J:=SubItems.Add(Format('总空间: %f GB',[d4/1024/1024/1024*d2*d1])+Format('剩余空间: %f GB',[d3/1024/1024/1024*d2*d1])); 
    这里它一定要返回值才行!!
      

  2.   

    既然有编译错误提示, 双击某个错误提示, IDE会自动定位到无法编译的语句的。
      

  3.   

    第一个没法编译的语句是: if (driver<>'') and (getdrivetype(PChar(str))<>drive_cdrom) and (getdrivetype(PChar(str))<>DRIVE_REMOVABLE) then第二个没法编译的语句是:GetDiskFreeSpace(PChar(str),d1,d2,d3,d4);
      

  4.   

    把你引用的单元列表(uses ......这部分)帖出来看看。
      

  5.   

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, ImageEx, ImgList, StdCtrls, Grids, jpeg,
      CheckLst, ComCtrls;
      

  6.   

    重启delphi或重启计算机后再试试测试过了的确运行正常,是不是system.pas和windows.pas有问题?
      

  7.   

    引用不了  System   会提示错误 [Error] Frm_Main_U.pas(8): Identifier redeclared: 'System'
      

  8.   

    我重启了N次了啊,都没用,重新装过DELPHI 和 系统了,也没用!!!
      

  9.   

    嗯,就是因为编译不过,我才试用 system.pas 的,用了也不过
      

  10.   

    还是看不出哪有问题。你有没有在程序里定义了自己的getdrivetype函数?
      

  11.   

    要不给你发一个system.pas,你把你原来的覆盖掉然后再试试
      

  12.   

    没有定义 getdrivetype函数 
      

  13.   

    请发一个你们的 system.pas 给我试试看看啊,谢谢啦, 我的QQ是:65684643
      

  14.   

    这是你在编译时delphi提示的吗?那是windows.pas的问题,这个函数就是这个单元中的
      

  15.   

    project options -> compiler
    把 syntax options 里的 extended syntax 和 huge strings 勾上
      

  16.   

    谢谢 Seamour 
    你的答案
    project options -> compiler 
    把 syntax options 里的 extended syntax 和 huge strings 勾上 解决了我的问题,调试通过了!!谢谢啦!!