Write a function that determines if the file is locked - useful!

xiaoxiao2021-03-06  74

Today, this feature is used in the project, write it out, if you use the place, directly Ctrl C, huh, huh.

The function is as follows:

bool IsFileLocked (LPCTSTR szFileName) {if (szFileName == NULL) return false; HANDLE ret; ret = CreateFile (szFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (ret == INVALID_HANDLE_VALUE) {return true; } Closehandle (return); Return False;}

'-------------------------------------------' Please indicate the source 'author: Don just fine' E-mail: tanaya@163.com '------------------------------------- --------

转载请注明原文地址:https://www.9cbs.com/read-120519.html

New Post(0)