本文整理自网络,侵删。
//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;
相关阅读 >>
Delphi serial number of an usb flash drive 获取u盘硬件序列号
Delphi firedac 下的 sqlite [1] - 前言
Delphi 创建win桌面快捷方式,实现360桌面图标数字提示 或 类似安卓的右上角的数字提示
Delphi 在rxrichedit中插入图片的完美解决方法
Delphi timagelist 中使用 透明 png 图标
更多相关阅读请进入《Delphi》频道 >>