本文整理汇总了C#中System.IO.MemoryMappedFiles.MemoryMappedFile.GetAccessControl方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryMappedFile.GetAccessControl方法的具体用法?C# MemoryMappedFile.GetAccessControl怎么用?C# MemoryMappedFile.GetAccessControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.MemoryMappedFiles.MemoryMappedFile
的用法示例。
在下文中一共展示了MemoryMappedFile.GetAccessControl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStart
protected override void OnStart(string[] args)
{
base.OnStart(args);
client = new WlanClient();
//Miofile = "C:\\" + DateTime.Now.ToLongDateString() + "-" +DateTime.Now.ToShortTimeString() + "_catture.txt";
//System.IO.File.AppendAllText("c:\\catture.txt", "PARTOOOOOOOOOOOOOOOOOOOOO\r\n");
// Initialize data structure
aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Interval = default_interval;
//System.IO.File.AppendAllText("c:\\catture.txt", "PARTOOOOOOOOOOOOOOOOOOOOO\r\n");
//initialize the mutex
mut = new Mutex(false,"Global\\ServiceMutex");
MutexSecurity mSec = mut.GetAccessControl();
var rule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
MutexRights.Modify
| MutexRights.Synchronize
| MutexRights.TakeOwnership
| MutexRights.ReadPermissions,
AccessControlType.Allow);
mSec.AddAccessRule(rule);
mut.SetAccessControl(mSec);
// Set the time interval
//System.IO.File.AppendAllText("c:\\catture.txt", "PARTOOOOOOOOOOOOOOOOOOOOO\r\n");
// File Mapping creation
try
{
mmf = MemoryMappedFile.CreateNew("Global\\Broadcast", MappedFileDimension, MemoryMappedFileAccess.ReadWrite);
}
catch (Exception e)
{
System.IO.File.AppendAllText("c:\\catture.txt", e.ToString());
}
var mmfSec = mmf.GetAccessControl();
mmfSec.SetAccessRule(new AccessRule<MemoryMappedFileRights>(new SecurityIdentifier(WellKnownSidType.WorldSid, null),MemoryMappedFileRights.FullControl | MemoryMappedFileRights.Read, AccessControlType.Allow));
mmf.SetAccessControl(mmfSec);
//System.IO.File.AppendAllText("c:\\catture.txt", "PARTOOOOOOOOOOOOOOOOOOOOO\r\n");
stream = mmf.CreateViewStream(0, MappedFileDimension, MemoryMappedFileAccess.ReadWrite);
//System.IO.File.AppendAllText("c:\\catture.txt", "FINISCO PARTENZA\r\n");
aTimer.Enabled = true;
}