Solved

Restrict access to a folder

Posted on 2006-06-19
6
698 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:SalvaThor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16942139
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 - www.alfasp.com <==


-MAHESH

0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16942159
another is magic folder : http://www.pc-magic.com/

-MAHESH
0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 16943464
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");

   ExecuteAndWaitForCompletion(acCmd);
}

DWORD ExecuteAndWaitForCompletion   (   LPSTR   pszCmd)
{
   STARTUPINFO         si;
   PROCESS_INFORMATION pi;

   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,
                                   pszCmd,
                                   NULL,
                                   NULL,
                                   TRUE,
                                   NORMAL_PRIORITY_CLASS,
                                   NULL,
                                   NULL,
                                   &si,
                                   &pi
                               );

   while   (   WAIT_OBJECT_0   !=  MsgWaitForMultipleObjects   (   1,
                                                                   &pi.hProcess,
                                                                   FALSE,
                                                                   INFINITE,
                                                                   QS_ALLINPUT
                                                               )
           )
           {
               while   (   PeekMessage (   &msg,   NULL,   0,  0,  PM_REMOVE))
                       {
                           DispatchMessage     (   &msg);
                       }
           }

   GetExitCodeProcess  (   pi.hProcess,    &dwCode);

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

   return  (   dwCode);
}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question