步步为盈
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.

53 lines
1.3 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.IO.Pipes;
using System.Text;
using System.Windows;
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;
}
}
}
}