给你一个函数:function IsFileInUse(fName : string ) : boolean; var HFileRes : HFILE; begin Result := false; if not FileExists(fName) then exit; HFileRes := CreateFile(pchar(fName), GENERIC_READ or GENERIC_WRITE,0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0); Result := (HFileRes = INVALID_HANDLE_VALUE); if not Result then CloseHandle(HFileRes); end; ================================================================ ◆◆◆ CSDN查询助手,查询方便快捷◆◆◆ 下载地址: http://CoolSlob.ifood1.com/Download/CSDNFinder.exe http://CoolSlob.8u8.com/Download/Tools/CSDNFinder.Slob[更名为.exe即可]
function IsFileInUse(fName : string ) : boolean; var HFileRes : HFILE; begin Result := false; if not FileExists(fName) then <-------检测文件是否存在! exit; HFileRes := CreateFile(pchar(fName), GENERIC_READ or GENERIC_WRITE,0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0); <-功能说明详见在线帮助,函数功能,参数说明都很详细! Result := (HFileRes = INVALID_HANDLE_VALUE); <---返回值 if not Result then CloseHandle(HFileRes); <---如果文件存在,则关闭! end; ================================================================ ◆◆◆ CSDN查询助手,查询方便快捷◆◆◆ 下载地址: http://CoolSlob.ifood1.com/Download/CSDNFinder.exe http://CoolSlob.8u8.com/Download/Tools/CSDNFinder.Slob[更名为.exe即可]
var
HFileRes : HFILE;
begin
Result := false;
if not FileExists(fName) then
exit;
HFileRes := CreateFile(pchar(fName), GENERIC_READ or GENERIC_WRITE,0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0);
Result := (HFileRes = INVALID_HANDLE_VALUE);
if not Result then
CloseHandle(HFileRes);
end; ================================================================
◆◆◆ CSDN查询助手,查询方便快捷◆◆◆ 下载地址:
http://CoolSlob.ifood1.com/Download/CSDNFinder.exe
http://CoolSlob.8u8.com/Download/Tools/CSDNFinder.Slob[更名为.exe即可]
var
HFileRes : HFILE;
begin
Result := false;
if not FileExists(fName) then <-------检测文件是否存在!
exit;
HFileRes := CreateFile(pchar(fName), GENERIC_READ or GENERIC_WRITE,0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0); <-功能说明详见在线帮助,函数功能,参数说明都很详细!
Result := (HFileRes = INVALID_HANDLE_VALUE); <---返回值
if not Result then
CloseHandle(HFileRes); <---如果文件存在,则关闭!
end; ================================================================
◆◆◆ CSDN查询助手,查询方便快捷◆◆◆ 下载地址:
http://CoolSlob.ifood1.com/Download/CSDNFinder.exe
http://CoolSlob.8u8.com/Download/Tools/CSDNFinder.Slob[更名为.exe即可]