xRootEE
asked on
NtDeleteFile usage
I'm wondering how can I use NtDeleteFile to delete C:\file.txt
It's being called from a Native Application, and the actual return code is something like -10279875....
lpPathName = "\\??\\C:\\file.txt"
Win XP SP2 + WDK 2008
It's being called from a Native Application, and the actual return code is something like -10279875....
lpPathName = "\\??\\C:\\file.txt"
Win XP SP2 + WDK 2008
PathNameString.Length = 19;
PathNameString.Buffer = (WCHAR *)lpPathName;
PathNameString.MaximumLength = PathNameString.Length+sizeof(WCHAR);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = NULL;
ObjectAttributes.ObjectName = &PathNameString;
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE| OBJ_INHERIT;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
errCode = NtDeleteFile(&ObjectAttributes);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please ignore my comment.
This is more of jkr's field than mine...
This is more of jkr's field than mine...
ASKER
That just works =)
Thank you very much.
Thank you very much.
BTW, you can simplify that and make it more error proof using
UNICODE_STRING PathNameString;
OBJECT_ATTRIBUTES ObjectAttributes;
RtlCreateUnicodeString(&PathNameString,lpPathName);
InitializeObjectAttributes( &ObjectAttributes, &PathNameString, OBJ_CASE_INSENSITIVE, NULL, NULL );
errCode = NtDeleteFile(&ObjectAttributes);
ASKER
Thank you =) That's much better.
These types of errors are normally down to network access-related issues...