关于c#中Mutex类如何设置mutexSecurity为Everyone?

lile_cq 2008-11-06 04:16:12
初学c#,请教各位
public Mutex (
bool initiallyOwned,
string name,
out bool createdNew,
MutexSecurity mutexSecurity
)
这个函数如何把最后一个参数设置成类似于c中Everyone的安全属性啊?
...全文
361 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lile_cq 2008-11-07
  • 打赏
  • 举报
回复
太谢谢了,我试了可以用。你太强了
gomoku 2008-11-06
  • 打赏
  • 举报
回复
我没有测试,不过你不妨试试看:

SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
MutexAccessRule allowEveryone = new MutexAccessRule(everyone, MutexRights.FullControl, AccessControlType.Allow);
MutexSecurity mutexSecurity = new MutexSecurity();
mutexSecurity.AddAccessRule( allowEveryone );

bool createNew;
Mutex mutex = new Mutex(false, "MyMutex", out createNew, mutexSecurity);

111,089

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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