本文整理自网络,侵删。
//delphi 检测文件是否被占用
function IsFileInUse(AName: string): boolean;
var
hFileRes: HFILE;
begin
Result := False;
if not FileExists(AName) then exit;
hFileRes := CreateFile(PChar(AName), 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;
相关阅读 >>
Delphixe4 版本中,已针对移动平台 引入了 arc 模型
Delphi xe2 idhttp 获取utf-8编码中文网页
Delphi timage保存图片到stream及从stream中取图片
更多相关阅读请进入《Delphi》频道 >>