|
|
@ -7,13 +7,37 @@ namespace Utils |
|
|
|
{ |
|
|
|
public class MemoryHelper |
|
|
|
{ |
|
|
|
public static string GetMemoryToken() |
|
|
|
{ |
|
|
|
string memoryName = string.Empty; |
|
|
|
string[] args = Environment.GetCommandLineArgs(); |
|
|
|
foreach (var arg in args) |
|
|
|
{ |
|
|
|
if (arg.StartsWith("uid:")) |
|
|
|
{ |
|
|
|
memoryName = arg; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var result = MemoryHelper.ReadMMF(memoryName); |
|
|
|
|
|
|
|
if (result.isOk) |
|
|
|
{ |
|
|
|
return result.content; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
System.Environment.Exit(0); |
|
|
|
return string.Empty; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 写入映射文件
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="mapname"></param>
|
|
|
|
/// <param name="content"></param>
|
|
|
|
public static bool WriteMMF(string mapname, string content) |
|
|
|
public static bool WriteMMF(string mapname, string content) |
|
|
|
{ |
|
|
|
MemoryMappedFile mmf = MemoryMappedFile.CreateOrOpen(mapname, 1000, MemoryMappedFileAccess.ReadWrite); |
|
|
|
if (!string.IsNullOrEmpty(content)) |
|
|
|