Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to secure delete files

How to secure delete files

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gmlnd
    wrote on last edited by
    #1

    I have a file deleter program that deletes cookies and temporary internet files, however, it sends the files to the recycle bin. Is it possible to secure delete the files, this means that the files are not moved to the "recycle bin", but rather are actually fully deleted from the hard drive.

    D 1 Reply Last reply
    0
    • G gmlnd

      I have a file deleter program that deletes cookies and temporary internet files, however, it sends the files to the recycle bin. Is it possible to secure delete the files, this means that the files are not moved to the "recycle bin", but rather are actually fully deleted from the hard drive.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      What method are you currently using to delete with?

      G 1 Reply Last reply
      0
      • D David Crow

        What method are you currently using to delete with?

        G Offline
        G Offline
        gmlnd
        wrote on last edited by
        #3

        I use the following class to delete files. void CFileDeleter::Initialize() { m_nDeleteType = 0; LoadDeleteType(); } void CFileDeleter::LoadDeleteType() { HKEY hKey; long lRet; int nType = 0; DWORD dw = sizeof(int); DWORD dwType = REG_DWORD; lRet = RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\iISoftware\\iIWiper",0,KEY_ALL_ACCESS,&hKey); if(lRet == ERROR_SUCCESS) { lRet = RegQueryValueEx(hKey,"DeleteType",0,&dwType,(LPBYTE)&nType,&dw); if(lRet == ERROR_SUCCESS) { m_nDeleteType = nType; } } } BOOL CFileDeleter::FileDeleteOperation(LPTSTR lpszFile) { DWORD dwAttrib; dwAttrib = GetFileAttributes(lpszFile); if (dwAttrib == 0xFFFFFFFF) { return FALSE; } switch(m_nDeleteType) { case DELETE_RECYCLE: { SHFILEOPSTRUCT f; ZeroMemory(&f, sizeof(SHFILEOPSTRUCT)); f.wFunc = FO_DELETE; f.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; lpszFile[lstrlen(lpszFile)+1] = 0; f.pFrom = lpszFile; SHFileOperation(&f); break; } case DELETE_DELETE: DeleteFile(lpszFile); break; default: { SHFILEOPSTRUCT f; ZeroMemory(&f, sizeof(SHFILEOPSTRUCT)); f.wFunc = FO_DELETE; f.fFlags = FOF_ALLOWUNDO; f.pFrom = lpszFile; SHFileOperation(&f); break; } } return TRUE; }

        D 1 Reply Last reply
        0
        • G gmlnd

          I use the following class to delete files. void CFileDeleter::Initialize() { m_nDeleteType = 0; LoadDeleteType(); } void CFileDeleter::LoadDeleteType() { HKEY hKey; long lRet; int nType = 0; DWORD dw = sizeof(int); DWORD dwType = REG_DWORD; lRet = RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\iISoftware\\iIWiper",0,KEY_ALL_ACCESS,&hKey); if(lRet == ERROR_SUCCESS) { lRet = RegQueryValueEx(hKey,"DeleteType",0,&dwType,(LPBYTE)&nType,&dw); if(lRet == ERROR_SUCCESS) { m_nDeleteType = nType; } } } BOOL CFileDeleter::FileDeleteOperation(LPTSTR lpszFile) { DWORD dwAttrib; dwAttrib = GetFileAttributes(lpszFile); if (dwAttrib == 0xFFFFFFFF) { return FALSE; } switch(m_nDeleteType) { case DELETE_RECYCLE: { SHFILEOPSTRUCT f; ZeroMemory(&f, sizeof(SHFILEOPSTRUCT)); f.wFunc = FO_DELETE; f.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; lpszFile[lstrlen(lpszFile)+1] = 0; f.pFrom = lpszFile; SHFileOperation(&f); break; } case DELETE_DELETE: DeleteFile(lpszFile); break; default: { SHFILEOPSTRUCT f; ZeroMemory(&f, sizeof(SHFILEOPSTRUCT)); f.wFunc = FO_DELETE; f.fFlags = FOF_ALLOWUNDO; f.pFrom = lpszFile; SHFileOperation(&f); break; } } return TRUE; }

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Just omit the FOF_ALLOWUNDO flag.

          G 1 Reply Last reply
          0
          • D David Crow

            Just omit the FOF_ALLOWUNDO flag.

            G Offline
            G Offline
            gmlnd
            wrote on last edited by
            #5

            Thank's, I deleted the FOF_ALLOWUNDO flag. Now I don't see the deleted files in the recycle bin anymore, but when I click on the Clean File in my program, before it deletes, for every cookie a dialog box pops: Are you sure you want to delete "cookie name"? Is there any way I could stop that message from popping up?

            D 1 Reply Last reply
            0
            • G gmlnd

              Thank's, I deleted the FOF_ALLOWUNDO flag. Now I don't see the deleted files in the recycle bin anymore, but when I click on the Clean File in my program, before it deletes, for every cookie a dialog box pops: Are you sure you want to delete "cookie name"? Is there any way I could stop that message from popping up?

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              azi_games wrote: Is there any way I could stop that message from popping up? Adding FOF_NOCONFIRMATION, I presume.

              G 1 Reply Last reply
              0
              • D David Crow

                azi_games wrote: Is there any way I could stop that message from popping up? Adding FOF_NOCONFIRMATION, I presume.

                G Offline
                G Offline
                gmlnd
                wrote on last edited by
                #7

                Thank you for your help.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups