DeleteFileW returns incorrect error code in Vista for DLLs
- From: "Jon Potter" <gpsoft@xxxxxxxxxxxxx>
- Date: Wed, 15 Aug 2007 08:19:33 +1000
Hi,
I've found what seems to be a bug in the DeleteFileW function in Vista, I was just wondering if this was known about already:
It seems that DeleteFileW can return an incorrect error code when attempting to delete a DLL that is in use, _if elevation is used_.
For example, deleting an in-use DLL from the Program Files folder. Normally this would return ERROR_SHARING_VIOLATION, however because elevation is needed, ERROR_ACCESS_DENIED is return. This is fine, but if elevation permission is then granted and the delete is tried again, ERROR_ACCESS_DENIED is still returned.
You can demonstrate this quite easily using a DOS prompt. First, a non-admin DOS prompt:
C:\Program Files\MSN Messenger>del msnmsgr.exe
C:\Program Files\MSN Messenger\msnmsgr.exe
Access is denied.
C:\Program Files\MSN Messenger>del msgsres.dll
C:\Program Files\MSN Messenger\msgsres.dll
Access is denied.
These are the expected results. However, with an administrator DOS prompt, the results are surprising:
C:\Program Files\MSN Messenger>del msgsres.dll
C:\Program Files\MSN Messenger\msgsres.dll
Access is denied.
C:\Program Files\MSN Messenger>del msnmsgr.exe
C:\Program Files\MSN Messenger\msnmsgr.exe
The process cannot access the file because it is being used by another process.
As you can see, the correct error code is returned for the .exe, but the ..dll error code is wrong (even though both files are in use.)
In XP, or in the case of in-use files in Vista for which elevation is not needed in order to delete them, ERROR_SHARING_VIOLATION is returned for both EXEs and DLLs.
Can anyone confirm this?
Cheers,
Jon
.
- Follow-Ups:
- Re: DeleteFileW returns incorrect error code in Vista for DLLs
- From: Alexander Grigoriev
- RE: DeleteFileW returns incorrect error code in Vista for DLLs
- From: "Jeffrey Tan[MSFT]"
- Re: DeleteFileW returns incorrect error code in Vista for DLLs
- Prev by Date: MMC Command Read Buffer Capacity
- Next by Date: CreateFile Question
- Previous by thread: MMC Command Read Buffer Capacity
- Next by thread: RE: DeleteFileW returns incorrect error code in Vista for DLLs
- Index(es):
Relevant Pages
|