初学c#,请教各位
public Mutex (
bool initiallyOwned,
string name,
out bool createdNew,
MutexSecurity mutexSecurity
)
这个函数如何把最后一个参数设置成类似于c中Everyone的安全属性啊?

解决方案 »

  1.   

    我没有测试,不过你不妨试试看:    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);