//////////////////////////////////////////////////////////////////////////
Function: Erasefile
Parameters: strFilePath (full path to file)
Features: Non-recoverable deletion of individual files
Time:
//////////////////////////////////////////////////////////////////////////
BOOL erasefile (LPWStr strFilePath)
{
HANDLE hfile = Invalid_handle_value;
BOOL bok = FALSE;
Char zerobuf[512];
int index = 0;
ZeroMemory (zerobuf, sizeof (ZEROBUF));
Do
{
setfileattributes (strFilePath, file_attribute_normal);
hfile = CreateFile (strFilePath,
Generic_read | Generic_write,
0,
NULL,
open_existing,
File_attribute_normal,
NULL);
if (hfile = = Invalid_handle_value)
{
Break
;
}
DWORD nsize = GetFileSize (hfile, NULL);
int nwritecount = nsize/sizeof (zerobuf);
nwritecount = max (Nwritecount, 1);
DWORD dwbytes = 0;
for
(int i = 0; i < Nwritecount; i++)
{
WriteFile (hfile, Zerobuf, sizeof (ZEROBUF), &dwbytes, NULL);
}
index++;
CloseHandle (hfile);
} while (index < 1);
bOK = deletefile (strFilePath);
return bok;
}
Windows non-recoverable delete files