program CopyFile;uses
  Windows;Var
   Old_File:String;
   New_File:String;
begin
   Old_File := 'C:\123.txt';
   New_File := 'D:\123.txt';
   CopyFile(PChar(Old_File),PChar(New_File),False);
end.[Error] CopyFile.dpr(12): '.' expected but '(' foundCopyFile 不是 windows API的吗???晕...在这儿应该怎么用呢??

解决方案 »

  1.   

    不会吧,我用你的代码,在D6下已测试通过。
    COPY(‘C:\123。TXT’,‘D:\123。TXT’,FALSE)试试。
      

  2.   

    另外想附带请问一个问题,如果我想在DOS下输出一个字符串怎么写?就是用在以上程序上记得在学PASCAL的时候是writeln,现在不能这样用,请问应该怎么输出呢?
      

  3.   

    不是CopyFile的问题吧,我看你的代码没有错误啊这种错误一般是编译器检查到一个结构类型,然后继续访问内部结构的时候报错,你确认是这里问题吗?
      

  4.   

    CopyFile('C:\123.txt','D:\123.txt',False); 测试,还是那样?奇怪了...........[Error] CopyFile.dpr(12): '.' expected but '(' found
      

  5.   

    是这样的,我想做一个无窗体的程序,按照之前的做法做了前面的步骤,就是写这CopyFile时出了问题
    写CopyFile然后再跟着输入(时,不是应该会有一些帮助出来吗?这回跟本没有。我后来再把shellapi也引用上,也还是不行
    就上面这么多代码了
      

  6.   

    program CopyFile; <------- 和CopyFile重名了,晕了对不起大家了,不好意思
      

  7.   

    to jadesun (玉阳)   :
       我帮你做好了~~~
       假设你原来的目录为 c:\tyn1   你现在想备份到 c:\tyn2目录下
    ~~~~~~
    procedure TForm1.Button1Click(Sender: TObject);
    var
     FileOpStruct :TSHFileOpStruct;
     Buf1 :array [0..127] of Char;
     Buf2 :array [0..127] of Char;
     Str1,Str2 :String;
    begin
     Str1 :='c:\tyn1';
     Str2 :='c:\tyn2';
     FillChar(Buf1,SizeOf(Buf1),0);
     FillChar(Buf2,SizeOf(Buf2),0);
     StrPCopy(Buf1,Str1);
     StrPCopy(Buf2,Str2);
     with FileOpStruct do
     begin
       Wnd :=Handle;
       wFunc :=FO_COPY;
       pFrom :=@Buf1;
       pTo :=@Buf2;
       fFlags :=FOF_SIMPLEPROGRESS;
       fAnyOperationsAborted :=False;
       hNameMappings :=nil;
       lpszProgressTitle :='拷贝文件';
     end;
     SHFileOperation(FileOpStruct);
    end;  
    接贴吧~    ^_^