在编写一个非常简单的Delphi程序时,遇到一个奇怪的问题
[DCC Error] Project2.dpr(25): E2010 Incompatible types: ‘Cardinal’ and ‘TSearchRec’
var searchResult : TSearchRec; begin // Try to find regular files matching Unit1.d* in the current dir if FindFirst('Unit1.d*', faAnyFile, searchResult) = 0 then begin repeat ShowMessage('File name = '+searchResult.Name); ShowMessage('File size = '+IntToStr(searchResult.Size)); until FindNext(searchResult) <> 0; // Must free up resources used by these successful finds FindClose(searchResult); end; end;
上述代码来自【参考1】
错误始终指向 FindClose(searchResult); 这一句,百思不得其解,后来搜索到了一个解释【参考2】,调换 uses 中的 windows和 sysutils 位置即解决……
参考:
1.http://www.delphibasics.co.uk/RTL.asp?Name=FindFirst FindFirst Function
2.http://www.delphipages.com/forum/showthread.php?t=145983
牛批。。。这个问题也能解决。。。。想问你是怎么测试的。。。
搜索到的而已,有人碰到了才好解决。