sr:TsearchRec;     FindFirst('D:\图像数据\*.jpg',fareadonly,sr); 为什么提示“ fareadonly” 错误!

解决方案 »

  1.   

    FindFirst('D:\delphi\*.jpg',$00000001,sr);
    Constant            Value   Description
    faReadOnly $00000001   Read-only files
    faHidden          $00000002   Hidden files
    faSysFile          $00000004   System files
    faVolumeID $00000008   Volume ID files
    faDirectory $00000010   Directory files
    faArchive          $00000020  Archive files
    faAnyFile          $0000003F   Any file
      

  2.   

    function FileGetSize(FileName:string): Int64;
    var w32fd: TWin32FindData; h: THandle;
    begin
      Result := 0;
      if FileName='' then Exit;
      h := Windows.FindFirstFile(PChar(FileName),w32fd);
      if h <> INVALID_HANDLE_VALUE then
         with w32fd do Result := nFileSizeHigh * MAXDWORD + nFileSizeLow;
      Windows.FindClose(h);
    end;
      

  3.   

    1.要注意大小写,那是个常量
    2.可以用API findfirstfile
      下面是关于 findfirstfile的说明(英文的)
    Unit
    Windows.PasSyntax
    FindFirstFile(
    lpFileName: PChar; {a pointer to a filename}
    var lpFindFileData: TWin32FindData {a pointer to a TWin32FindData structure}
    ): THandle; {returns a search handle}Description
    This function searches the current directory for the first file that matches the filename specified by the lpFileName parameter. This function will find both files and subdirectories, and the filename being searched for can contain wild cards.Parameter:
    lpFileName: A pointer to a null terminated string containing the path and filename for which to search. This filename may contain wild cards .lpFindFileData: A pointer to a TWin32FindData data structure containing information about the file or subdirectory that was found. The TWin32FindData data structure is defined as:TWin32FindData = record
    dwFileAttributes: DWORD; {file attributes}
    ftCreationTime: TFileTime; {file creation time}
             ftLastAccessTime: TFileTime; {last file access time}
    ftLastWriteTime: TFileTime; {last file modification time}
    nFileSizeHigh: DWORD; {high double word of file size}
    nFileSizeLow: DWORD; {low double word of file size}
    dwReserved0: DWORD; {reserved for future use}
    dwReserved1: DWORD; {reserved for future use}
    cFileName: array[0..MAX_PATH - 1] of AnsiChar; {long file name}
             cAlternateFileName: array[0..13] of AnsiChar; {short file name}
    end; dwFileAttributes: Specifies the file attribute flags for the file. See the GetFileAttributes function for a list of possible file attribute flags. ftCreationTime: Specifies the time that the file was created. ftLastAccessTime: Specifies the time that the file was last accessed. ftLastWriteTime: Specifies the time that the file was last modified.         nFileSizeHigh: Specifies the high order double word of the file size. nFileSizeLow: Specifies the low order double word of the file size. dwReserved0: This member is reserved for future use, and its value is undetermined. dwReserved1: This member is reserved for future use, and its value is undetermined. cFileName: A null terminated string containing the long version of the filename. cAlternateFileName: A null terminated string containing the short (8.3) version of the filename.Return Value 
    If the function succeeds, it returns a search handle that can be used in subsequent calls to FindNextFile. If the function fails, it returns INVALID_HANDLE_VALUE.
    看不懂再说
      

  4.   

    谢谢各位了!  我已经找到问题的原因! 不是大小写的问题!
    而是! 在我的代码里面我用到 TADOquery里面的字段属性,刚好
    在这个字段里面有这个 fareadOnly 的常量,  而造成冲突。所以
    $00000001这个代替fareadOnly就没有问题了!