locking folder

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2005
Posts: 2
Reputation: gluber is an unknown quantity at this point 
Solved Threads: 0
gluber gluber is offline Offline
Newbie Poster

locking folder

 
0
  #1
Jul 3rd, 2005
hello, :eek:
hey guys do anyone know
code for locking folder on 98 & xp
help me pls :o
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,730
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 737
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: locking folder

 
0
  #2
Jul 3rd, 2005
Locked how? You can set it to be read-only and hidden using SetFileAttributes. That's a quick and easy way to prevent simple viewing of and writing to the directory:
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4.  
  5. void werror ( void )
  6. {
  7. char msg[BUFSIZ];
  8. DWORD err = GetLastError();
  9.  
  10. FormatMessage ( FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
  11. MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ), msg, BUFSIZ, NULL );
  12.  
  13. fprintf ( stderr, "%s", msg );
  14. exit ( EXIT_FAILURE );
  15. }
  16.  
  17. int main ( int argc, char *argv[] )
  18. {
  19. BOOL rc;
  20.  
  21. if ( argc < 2 ) {
  22. fprintf ( stderr, "usage: $prog <file>\n" );
  23. exit ( EXIT_FAILURE );
  24. }
  25.  
  26. rc = SetFileAttributes ( argv[1],
  27. FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY );
  28.  
  29. if ( rc == 0 )
  30. werror();
  31.  
  32. return EXIT_SUCCESS;
  33. }
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC