用WinAPI:
BOOL SetFileSecurity(
LPCTSTR lpFileName, // address of string for filename
SECURITY_INFORMATION SecurityInformation,
// type of information to set
PSECURITY_DESCRIPTOR pSecurityDescriptor
// address of security descriptor
);
如:::SetFileSecurity(szFileName, DACL_SECURITY_INFORMATION, psd);其中 psd 的取得見上一篇:http://dave3068.blogspot.com/2009/01/securityattributeslpsecuritydescriptor.html
另外,對上一篇的補充:
SECURITY_ATTRIBUTES 中 lpSecurityDescriptor 的使用還可以使用 API :
SetSecurityDescriptorDacl
SetSecurityDescriptorControl
等。
不過感覺一般情況下還是這個 ConvertStringSecurityDescriptorToSecurityDescriptor 方便些 :)。
要如何使用就要看具體的場合了。
//EOF

0 comments:
Post a Comment