比如删除 C:\WINDOWS\NOTEPAD.EXE这样写对不?var WinPath: array[0..255] of Char;begin  GetWindowsDirectory(WinPath, 256);
  DeleteFile(Pchar(WinPath)+'Notepad.exe');end;

解决方案 »

  1.   

    var WinPath: array[0..255] of Char;
    begin
      GetWindowsDirectory(WinPath, 256);
      DeleteFile(Pchar(WinPath)+'\Notepad.exe');
                                ~~~~ 
    end;
      

  2.   

    var WinPath: array[0..255] of Char;begin  GetWindowsDirectory(WinPath, 256);  DeleteFile(string(winpath)+'\Notepad.exe');
    end;
      

  3.   

    为什么用Pchar不行,而要用string,而且要加“\”?
      

  4.   

    PChar是指针类型,当然不能直接与字符串类型进行 + 的运算GetWindowsDirectory(WinPath, 256);后,WinPath的前几个元素的内容是C:\windows这样(假设),你可以Showmessage(string(winpath));看一下。要生成c:\windows\notepad.exe这样的字串,当然要 + '\notepad.exe'了