设置文件夹访问权限

fluckford 2005-10-21 05:42:33
系统管理员权创建的文件夹普通用户没有写权限和创建文件权限,如何用VC实现程序修改该文件夹访问的权限,实现普通用户可以控制该文件夹。生成的程序是由系统管理员来运行的,各位大哥不用担心程序设计时的权限问题。
...全文
916 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
calabash_b 2005-11-05
  • 打赏
  • 举报
回复
mark
Qiushen 2005-11-01
  • 打赏
  • 举报
回复
我解决了,在MSDN里找到的
(取自MSDN)

#define _WIN32_WINNT 0x0500

#include <windows.h>
#include <sddl.h>
#include <stdio.h>

BOOL CreateMyDACL(SECURITY_ATTRIBUTES *);

void main()
{
SECURITY_ATTRIBUTES sa;

sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;

// Call function to set the DACL. The DACL
// is set in the SECURITY_ATTRIBUTES
// lpSecurityDescriptor member.
if (!CreateMyDACL(&sa))
{
// Error encountered; generate message and exit.
printf("Failed CreateMyDACL\n");
exit(1);
}

// Use the updated SECURITY_ATTRIBUTES to specify
// security attributes for securable objects.
// This example uses security attributes during
// creation of a new directory.
if (0 == CreateDirectory(TEXT("C:\\MyFolder"), &sa))
{
// Error encountered; generate message and exit.
printf("Failed CreateDirectory\n");
exit(1);
}

// Free the memory allocated for the SECURITY_DESCRIPTOR.
if (NULL != LocalFree(sa.lpSecurityDescriptor))
{
// Error encountered; generate message and exit.
printf("Failed LocalFree\n");
exit(1);
}
}

BOOL CreateMyDACL(SECURITY_ATTRIBUTES * pSA)
{
TCHAR * szSD = TEXT("D:") // Discretionary ACL
TEXT("(D;OICI;GA;;;BG)") // Deny access to built-in guests
TEXT("(D;OICI;GA;;;AN)") // Deny access to anonymous logon
TEXT("(A;OICI;GRGWGX;;;AU)") // Allow read/write/execute to authenticated users
TEXT("(A;OICI;GA;;;BA)"); // Allow full control to administrators

if (NULL == pSA)
return FALSE;

return ConvertStringSecurityDescriptorToSecurityDescriptor(
szSD,
SDDL_REVISION_1,
&(pSA->lpSecurityDescriptor),
NULL);
}
Qiushen 2005-10-31
  • 打赏
  • 举报
回复
怎么编程实现啊,楼主把解决方法拿出来,我也想知道啊
andy_cai 2005-10-31
  • 打赏
  • 举报
回复
楼主把解决方法拿出来共享学习一下下
xjtuzhw 2005-10-31
  • 打赏
  • 举报
回复
可以利用系统功能,也可以自己设置权限
billy145533 2005-10-29
  • 打赏
  • 举报
回复
领分了
ncucf 2005-10-29
  • 打赏
  • 举报
回复
ntfs格式的磁盘,应该也提供了一些设置权限的函数吧!
楼主谈谈自己是如何解决的啊!
fluckford 2005-10-27
  • 打赏
  • 举报
回复
已经解决了,来个人领分
fluckford 2005-10-26
  • 打赏
  • 举报
回复
就没有人知道么,急用啊,

2,641

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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