在API中的CreateFile函数的第一个参数是文件的路径比如'd:\l.txt'.但是我想在文件l后面加个阿拉伯数字比如a:=0;  CreateFile('d:\l\l'+ INTTOSTR(a) +'.txt',.....);  a:=a+1; 这么写有问题.但如果换成是delphi自带的FileCreate函数就没有问题了.我想请高手帮忙用CreateFile应该怎么写呢?注意不是delphi自带的FileCreate函数. 谢谢了

解决方案 »

  1.   

    a:=0;  
    CreateFile(Pchar('d:\l\l'+ INTTOSTR(a) +'.txt'),.....);  
    a:=a+1; Note that : difference between pAnsichar and string.function FileCreate(const FileName: string): Integer; overload;HANDLE CreateFile(    LPCTSTR lpFileName, // pointer to name of the file  //Pchar 类型
        DWORD dwDesiredAccess, // access (read-write) mode 
        DWORD dwShareMode, // share mode 
        LPSECURITY_ATTRIBUTES lpSecurityAttributes, // pointer to security attributes 
        DWORD dwCreationDistribution, // how to create 
        DWORD dwFlagsAndAttributes, // file attributes 
        HANDLE hTemplateFile  // handle to file with attributes to copy  
       );
      

  2.   

    CreateFile第一个参数的类型是PChar
    所以CreateFile(PChar('d:\l\l'+ INTTOSTR(a) +'.txt'),...)