Check is file is locked
-
hi all, i need to check if a file is in use/locked. (then i have to delete the file if i want.) how can i do it using win32 api? regards Hari Krishnan
-
hi all, i need to check if a file is in use/locked. (then i have to delete the file if i want.) how can i do it using win32 api? regards Hari Krishnan
If the file exists but you can't open it for exclusive read access, you can safely assume it's locked by another process. Assuming you're using MFC, see
CFile
for more information. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com -
If the file exists but you can't open it for exclusive read access, you can safely assume it's locked by another process. Assuming you're using MFC, see
CFile
for more information. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.comHi, thanks, but i don't want to use CFile. After checking i want to delete the file. Is there any win32 way ? I've read now that CreateFile can check this. But is not sure about the arguments. Hari Krishnan
-
Hi, thanks, but i don't want to use CFile. After checking i want to delete the file. Is there any win32 way ? I've read now that CreateFile can check this. But is not sure about the arguments. Hari Krishnan
HFILE hFile = OpenFile(..., OF_SHARE_EXCLUSIVE);
if (HFILE_ERROR != hFile)
{
DeleteFile(...);
}