时间: 2021-07-31 作者:daque
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 {this is the trick!}, nil, open_existing, file_attribute_normal, 0); result := (hfileres = invalid_handle_value); if not result then closehandle(hfileres); end;