Function IsFileInUse(FileName: String): Boolean; //:判断.exe是否被执行Var HFileRes: HFile;Begin Result := False; If Not FileExists(FileName) Then Begin Exit; End; HFileRes := CreateFile(Pchar(FileName), GENERIC_READ Or GENERIC_WRITE, 0, Nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); Result := (HFileRes = INVALID_HANDLE_VALUE); If Not Result Then Begin CloseHandle(HFileRes); End;End;