Block access to a file
i want to make a program which block any file(like autorun.inf),so that no other program can read from it(just like a way,antivirus do) with c++ in windows. please help me. thanks开发者_运维百科.
You can open a file with a dwShareMode
of 0, which will
Prevents other processes from opening a file or device if they request delete, read, or write access.
So once your process opens the file, no other process will be able to open it, delete it, etc.
MSDN Reference
either set the NTFS ACLs on the file
or
use CreateFile() to open the file with dwShareMode=0 http://msdn.microsoft.com/en-us/library/aa363858(v=vs.85).aspx
You could encrypt the file. If it's unreadable it's unusable!
A simple xor will do.
精彩评论