请教,VC中创建的文件夹默认为只读,如何设置为可读写

shineheart 2011-12-12 10:28:45
请教,VC中创建的文件夹默认为只读,如何设置为可读写。我用的是createdirectory函数,后面那个参数不知道如何设置
...全文
275 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2012-01-19
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 shineheart 的回复:]
我看360里面有个功能“粉碎文件”就能做到不论文件是否被占用了,都可以删除掉。不知道他是如何实现的
[/Quote]
驱动一级实现。
shineheart 2012-01-19
  • 打赏
  • 举报
回复
我看360里面有个功能“粉碎文件”就能做到不论文件是否被占用了,都可以删除掉。不知道他是如何实现的
shineheart 2012-01-19
  • 打赏
  • 举报
回复
那有没有办法在程序占用的情况下删除掉呢,在程序中,如果不用到驱动级
shineheart 2011-12-23
  • 打赏
  • 举报
回复
有么有人知道呢
赵4老师 2011-12-23
  • 打赏
  • 举报
回复
mk:@MSITStore:C:\MSDN98\98VS\2052\winbase.chm::/devdoc/live/pdwbase/accctrl_2hf0.htm
Access Control
The security provisions of Microsoft® Windows NT® are automatically available to Win32-based applications. Every application running on the system is subject to the security imposed by the particular configuration of the local Windows NT implementation. Windows NT is the only platform that supports Win32 security.

The impact of Windows NT security on most Win32 functions is minimal, and a Win32-based application not requiring security functionality usually does not need to incorporate any special code. However, you can use the security features of Windows NT to provide a number of services to a Win32-based application.

This overview describes the Windows NT security model for controlling access to Win32 objects such as files, and for controlling access to administrative functions such as setting the system time or auditing user actions. The Access-Control Model topic provides a high-level description of the access control components and how they interact with each other. Following this description are topics that discuss the access-control components:

Access Tokens
Security Descriptors
Access-Control Lists (ACLs)
Access-Control Entries (ACEs)
Access Rights and Access Masks
Security Identifiers (SIDs)
The following topics discuss common access-control tasks:

Modifying an Object's Security Descriptor
Checking a Thread's Access to an Object
Controlling Child Object Creation
Controlling Access to an Object's Properties
Requesting Access Rights to an Object
The following topics provide sample code for access-control tasks:

Modifying an Object's ACLs
Creating a Security Descriptor for a New Object
Enabling and Disabling Privileges
Searching for a SID in an Access Token
Taking Object Ownership
Converting a Binary SID to String Format

shineheart 2011-12-14
  • 打赏
  • 举报
回复
能否说下第二个参数如何设置,我知道你那堆是从MSDN中拷贝出来的
赵4老师 2011-12-12
  • 打赏
  • 举报
回复
CreateDirectory
The CreateDirectory function creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory. Note that CreateDirectory does not have a template parameter, while CreateDirectoryEx does.

BOOL CreateDirectory(
LPCTSTR lpPathName, // pointer to directory path string
LPSECURITY_ATTRIBUTES lpSecurityAttributes // pointer to security descriptor
);

Parameters
lpPathName
Pointer to a null-terminated string that specifies the path of the directory to be created.
There is a default string size limit for paths of MAX_PATH characters. This limit is related to how the CreateDirectory function parses paths.

Windows NT: An application can transcend this limit and send in paths longer than MAX_PATH characters by calling the wide (W) version of CreateDirectory and prepending "\\?\" to the path. The "\\?\" tells the function to turn off path parsing; it lets paths longer than MAX_PATH be used with CreateDirectoryW. However, each component in the path cannot be more than MAX_PATH characters long. This also works with UNC names. The "\\?\" is ignored as part of the path. For example, "\\?\C:\myworld\private" is seen as "C:\myworld\private", and "\\?\UNC\bill_g_1\hotstuff\coolapps" is seen as "\\bill_g_1\hotstuff\coolapps".

lpSecurityAttributes
Windows NT: Pointer to a SECURITY_ATTRIBUTES structure. The lpSecurityDescriptor member of the structure specifies a security descriptor for the new directory. If lpSecurityAttributes is NULL, the directory gets a default security descriptor. The target file system must support security on files and directories for this parameter to have an effect.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧