使文件使用WIN32进行写保护 [英] To make File Write Protected using WIN32

查看:72
本文介绍了使文件使用WIN32进行写保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

谁能告诉我,如何使用WIN32以编程方式使文件受保护.
我已经创建了这样的文件:

Hi..

Can anyone tell me that, How to make a file as write Protected Programmatically using WIN32.
I have created the file like this:

HANDLE hFile = CreateFile("E:\\FileName.txt", GENERIC_READ,FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_ALWAYS, FILE_ATTRIBUTE_READONLY, 0);


创建文件后,当我尝试将该文件复制到其他位置时,不应将其复制.
在此先感谢.



有没有办法以编程方式使用用户帐户控制功能,而无需使用它..??


After creating a file, When i try to copy that file to other location, It should not copy.. Please sugest me..!

Thanks in Advance.



Is there any way to make it Programmatically with out using User Account Control Features.. ??

推荐答案

您已将文件设置为只读,但是这意味着任何人都可以阅读(并复制).如果您希望它受到完全保护,则必须使用用户帐户控制功能来保护它.
You have made your file read only but that means that anyone can read (and copy) it. If you want it to be totally protected then you must use the User Account Control features to secure it.


所以我从上一个问题中了解到,您希望文件对文件进行限制被复制.
如果我像黑客一样说话,我会说没有办法:(
说明:-
1. ACL保护可在Windows上使用,但是我可以运行Linux并轻松将其复制出来.
2.任何具有文件本身特权的高特权运行的进程,都可以复制该文件.

(2.)的解决方法:-
您可以编写一个服务来锁定该文件并阻止其被复制.
就像杀毒软件一样..
您可以使用这些链接进行研究,并可以查看是否还有其他方法可以... http://stackoverflow.com/questions/853805/locking-files-using-c-on-windows [ http://msdn.microsoft.com/zh-CN /library/windows/desktop/aa365203(v=vs.85).aspx [
So I came to understand from your previous question that you want your file to restrict it from being copied.
If I talk like a hacker I will say there is no way to do it :(
Explaination:-
1. ACL Protection work with windows, however I can run Linux and copy it out easily.
2.Any process running with high privilege with that of File itself,is able to copy that file.

Workaround for (2.):-
You can write a service for locking that file and stop it from being copied.
Like the way antiviruses do ..
You can research with these links and can check out if there is anyother way to do it... http://stackoverflow.com/questions/853805/locking-files-using-c-on-windows[^]
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365203(v=vs.85).aspx[^]


计算机通过将数据从一个内存位置复制到另一个位置来工作,并且又一个.
如果您有数据,则不想被复制...不要将其存储在计算机上.
(让人们使用复印机...)

如果您的问题是保护DATA(而不是文件...)免于被盗,则以只能将其解密的方式加密数据.到那时,复制文件本身将变得毫无头绪.
Computers work by copying data from a memory location into another, and another and another.
If you have data you don''t want to be copied ... don''t store them on computers.
(and let people use copy machines ...)

If your problem is to protected the DATA (not the file ...) from being somehow stolen then encrypt the data in a way you only can decrypt them. At that point, copying the file itself will be clueless.


这篇关于使文件使用WIN32进行写保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆