Restrict access to a folder

Hi everybody,

I have an MFC application that save some important facts in a folder called "Rma32", how can i prevent that a user access it from windows explorer or My PC icon, I have in my PC a folder "RRUbackups" that when I try to open send  me a message with "ACCESS DENIED"  and how to protect it of a user (that is not administrator) can delete it.
I want to do this always, when my program is running or not.

Best Regards.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

jkrConnect With a Mentor Commented:
You could remove all the ACLs for that folder except the one for 'admin'. The easiest way would be to spawn 'cacls.exe' for that, e.g.

DWORD ExecuteAndWaitForCompletion   (   LPSTR   pszCmd);

void RestrictAccess(char* psz) {

    char acCmd[MAX_PATH];

    wsprintf(acCmd,"cacls.exe /T /G Administrator:F");


DWORD ExecuteAndWaitForCompletion   (   LPSTR   pszCmd)
   STARTUPINFO         si;

   BOOL                bRes;

   DWORD               dwCode  =   0;

   MSG                           msg;

   ZeroMemory  (   &si,    sizeof  (   STARTUPINFO));

   si.cb           =   sizeof  (   STARTUPINFO);
   si.dwFlags      =   STARTF_USESHOWWINDOW;
   si.wShowWindow  =   SW_SHOWNORMAL;

   bRes    =   CreateProcess   (   NULL,

   while   (   WAIT_OBJECT_0   !=  MsgWaitForMultipleObjects   (   1,
               while   (   PeekMessage (   &msg,   NULL,   0,  0,  PM_REMOVE))
                           DispatchMessage     (   &msg);

   GetExitCodeProcess  (   pi.hProcess,    &dwCode);

   CloseHandle (   pi.hProcess);
   CloseHandle (   pi.hThread);

   return  (   dwCode);
You can't exactly password protect that way, but you can file encryption to encrypt files n hide them so that noone can access them. You may use components like Alfa File Protector to hide all files in a directory, protect them from any action etc. AFP also tag protection with password, so one needs a password to turn off the protection. It's a component / VC++ library - <==


another is magic folder :

All Courses

From novice to tech pro — start learning today.