ZwDeleteFile function (ntifs.h)
The ZwDeleteFile routine deletes the specified file.
NTSYSAPI NTSTATUS ZwDeleteFile( [in] POBJECT_ATTRIBUTES ObjectAttributes );
A pointer to an OBJECT_ATTRIBUTES structure that contains the attributes supplied by the caller to be used for the file object. These attributes would include the ObjectName and the SECURITY_DESCRIPTOR, for example. This parameter is initialized by calling the InitializeObjectAttributes macro.
ZwDeleteFile returns STATUS_SUCCESS or an appropriate error status representing the final completion status of the operation. Possible error status codes include the following:
||A temporary buffer required by this function could not be allocated.|
||The specified ObjectAttributes parameter was a NULL pointer, not a valid pointer to an OBJECT_ATTRIBUTES structure, or some of the specified ObjectAttributes structure members were invalid.|
||The ObjectAttributes parameter contained an ObjectName in the OBJECT_ATTRIBUTES structure that was invalid because an empty string was found after the OBJECT_NAME_PATH_SEPARATOR character.|
||The ObjectAttributes parameter contained an ObjectName member in the OBJECT_ATTRIBUTES structure that could not be found.|
||The ObjectAttributes parameter contained an ObjectName member in the OBJECT_ATTRIBUTES structure with an object path that could not be found.|
||The ObjectAttributes parameter did not contain a RootDirectory member, but the ObjectName member in the OBJECT_ATTRIBUTES structure was an empty string or did not contain an OBJECT_NAME_PATH_SEPARATOR character. This indicates incorrect syntax for the object path.|
ZwDeleteFile deletes the specified file object.
The ZwDeleteFile function is called after the InitializeAttributes macro is used to set attributes in the OBJECT_ATTRIBUTES structure for the file object to be deleted.
There are two alternate ways to specify the name of the file to be deleted with ZwDeleteFile:
- As a fully qualified pathname, supplied in the ObjectName member of the input ObjectAttributes
- As pathname relative to the directory file represented by the handle in the RootDirectory member of the input ObjectAttributes
|Minimum supported client||Available starting with Windows XP.|
|Header||ntifs.h (include Ntifs.h)|
|IRQL||PASSIVE_LEVEL (see Remarks section)|
|DDI compliance rules||PowerIrpDDis, HwStorPortProhibitedDDIs|