| | |
locking folder
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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:
C Syntax (Toggle Plain Text)
#include <stdio.h> #include <stdlib.h> #include <windows.h> void werror ( void ) { char msg[BUFSIZ]; DWORD err = GetLastError(); FormatMessage ( FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ), msg, BUFSIZ, NULL ); fprintf ( stderr, "%s", msg ); exit ( EXIT_FAILURE ); } int main ( int argc, char *argv[] ) { BOOL rc; if ( argc < 2 ) { fprintf ( stderr, "usage: $prog <file>\n" ); exit ( EXIT_FAILURE ); } rc = SetFileAttributes ( argv[1], FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY ); if ( rc == 0 ) werror(); return EXIT_SUCCESS; }
I'm here to prove you wrong.
![]() |
Similar Threads
- can you password protect a folder? (Windows 95 / 98 / Me)
- Folder Locking and Hiding in Windows XP (Computer Science)
- A real locking folder (C++)
Other Threads in the C Forum
- Previous Thread: changing loops (for to while) and (recursive to for)
- Next Thread: Why this program won't sort the right way?
| Thread Tools | Search this Thread |
#include * ansi append array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include infiniteloop initialization input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux list lists looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation overwrite owf pdf pointer pointers posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprogramming standard strchr string suggestions systemcall test testing threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi






