You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
using System;
|
|
using System.IO;
|
|
using System.IO.Pipes;
|
|
|
|
namespace Utils
|
|
{
|
|
public class MemoryHelper
|
|
{
|
|
/// <summary>
|
|
/// 获取token
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetMemoryToken()
|
|
{
|
|
try
|
|
{
|
|
string pipeId = Environment.GetCommandLineArgs()[1];
|
|
//创建输入类型匿名管道
|
|
using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, pipeId))
|
|
{
|
|
using (StreamReader sr = new StreamReader(pipeClient))
|
|
{
|
|
string temp;
|
|
|
|
do
|
|
{
|
|
temp = sr.ReadLine();
|
|
}
|
|
while (!temp.StartsWith("SYNC"));
|
|
|
|
|
|
while ((temp = sr.ReadLine()) != null)
|
|
{
|
|
return temp;
|
|
}
|
|
}
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|