{-----------------------------------------------------------------------------
函数名称: IsFileInUse
作者: Levon819@msn.com
日期: 2007-四月-09
参数: const fName: string
结果: Boolean
功能: 判断文件是否正在使用;
-----------------------------------------------------------------------------}
function IsFileInUse(const 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 {this is the trick!}, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
result := (HFileRes = INVALID_HANDLE_VALUE);
if not result then