如何使用WIN32进行文件复制保护 [英] How to make a file Copy Protect using WIN32

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

问题描述

你好..

我已经使用Core WIN32&创建了一个文件.代码是这样的:

Hello..

I have created a file using Core WIN32 & code is like this :

HANDLE hFile = CreateFile("E:\\FileName123.txt", GENERIC_READ,0,0,OPEN_ALWAYS, FILE_ATTRIBUTE_READONLY, 0);



这将在E:Drive中创建一个名为FileName123的文件.

我的问题是:当它将在E:Drive中创建文件时,它必须变为Copy Protect.也就是说,文件不应复制到其他位置.

请问您对此有何建议..

谢谢..



This will create a file with name FileName123 in E:Drive.

My question is: When it will create the file in E:Drive, it must become Copy Protect. That is., File should not copy to other location.

Please can u suggest any solution for this ..

Thanks..

推荐答案

一个简单的解决方案是以独占模式打开文件,即CFile :: shareExclusive.

希望这会有所帮助
jkchan
http://cgmath.blogspot.com
a simple solution is to open file with exclusive mode, ie CFile::shareExclusive.

Hopes this helps
jkchan
http://cgmath.blogspot.com


您已将"0"列为第三位参数(dwShareMode)到CreateFile()并以独占模式打开文件.

因此,在关闭句柄之前,无法再次打开文件.
You have passed ''0'' as third parameter (dwShareMode) to CreateFile() and the file is opened in exclusive mode.

Therefore, the file can''t be opened again until the handle is closed.


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

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