#include <windows.h> #include <ntdll.h> int WINAPI iWinMain() { #ifdef _WIN64 LPWSTR captionMsg = L"64-bit Application"; #else LPWSTR captionMsg = L"32-bit Application"; #endif LPWSTR finishedMsg = L"Failed!"; FILE_DISPOSITION_INFORMATION dispositionInfo; HANDLE FileHandle; OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING ObjectName; IO_STATUS_BLOCK IoStatusBlock; RtlInitUnicodeString(&ObjectName, L"\\??\\c:\\test.txt"); InitializeObjectAttributes( &ObjectAttributes, &ObjectName, OBJ_CASE_INSENSITIVE, NULL, NULL); if (NtOpenFile( &FileHandle, GENERIC_ALL, &ObjectAttributes, &IoStatusBlock, FILE_SHARE_DELETE, 0) == STATUS_SUCCESS) { dispositionInfo.DeleteFile = TRUE; if (NtSetInformationFile( FileHandle, &IoStatusBlock, &dispositionInfo, sizeof(FILE_DISPOSITION_INFORMATION), FileDispositionInformation) == STATUS_SUCCESS) { if (NtClose(FileHandle) == STATUS_SUCCESS) { MessageBoxW( NULL, L"Done...\nFile:\"C:\\test.txt\" deleted.", captionMsg, MB_ICONINFORMATION); finishedMsg = L"Finished!"; } } } MessageBoxW( NULL, finishedMsg, captionMsg, MB_ICONINFORMATION); return 0; }
Source:
http://www.mediafire.com/download/31cbw6onfxzr7am/FileDispositionInformation.rar