FindFirst的用法 ??

kl2000 2003-10-21 12:39:12
sr:TsearchRec;

FindFirst('D:\图像数据\*.jpg',fareadonly,sr);

为什么提示“ fareadonly” 错误!
...全文
305 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kl2000 2003-10-22
  • 打赏
  • 举报
回复
谢谢各位了! 我已经找到问题的原因! 不是大小写的问题!
而是! 在我的代码里面我用到 TADOquery里面的字段属性,刚好
在这个字段里面有这个 fareadOnly 的常量, 而造成冲突。所以
$00000001这个代替fareadOnly就没有问题了! 
Frewin 2003-10-21
  • 打赏
  • 举报
回复
up
vavyboyleon 2003-10-21
  • 打赏
  • 举报
回复
1.要注意大小写,那是个常量
2.可以用API findfirstfile
下面是关于 findfirstfile的说明(英文的)
Unit
Windows.Pas

Syntax
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.
看不懂再说
ly_liuyang 2003-10-21
  • 打赏
  • 举报
回复
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;
noil0125 2003-10-21
  • 打赏
  • 举报
回复
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
vavyboyleon 2003-10-21
  • 打赏
  • 举报
回复
大小写?

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧