mirror of
https://github.com/snltty/linker.git
synced 2025-12-24 12:38:04 +08:00
101 lines
3.1 KiB
C#
101 lines
3.1 KiB
C#
using cmonitor.libs;
|
||
using RDPCOMAPILib;
|
||
using System.Diagnostics;
|
||
|
||
namespace cmonitor.share.win
|
||
{
|
||
public partial class MainForm : Form
|
||
{
|
||
protected override CreateParams CreateParams
|
||
{
|
||
get
|
||
{
|
||
const int WS_EX_APPWINDOW = 0x40000;
|
||
const int WS_EX_TOOLWINDOW = 0x80;
|
||
CreateParams cp = base.CreateParams;
|
||
cp.ExStyle &= (~WS_EX_APPWINDOW);
|
||
cp.ExStyle |= WS_EX_TOOLWINDOW;
|
||
return cp;
|
||
}
|
||
}
|
||
|
||
private readonly Hook hook = new Hook();
|
||
private readonly ShareMemory shareMemory;
|
||
private readonly byte[] bytes;
|
||
private long version = 0;
|
||
public MainForm(string key, int size)
|
||
{
|
||
InitializeComponent();
|
||
|
||
bytes = new byte[size];
|
||
shareMemory = new ShareMemory(key, 1, size);
|
||
shareMemory.InitLocal();
|
||
}
|
||
|
||
private void OnLoad(object sender, EventArgs e)
|
||
{
|
||
#if RELEASE
|
||
this.FormBorderStyle = FormBorderStyle.None;
|
||
this.ShowInTaskbar = false;
|
||
this.WindowState = FormWindowState.Maximized;
|
||
#endif
|
||
TopMost = true;
|
||
CheckRunning();
|
||
}
|
||
|
||
private void CheckRunning()
|
||
{
|
||
hook.Start();
|
||
shareMemory.AddAttribute(0, ShareMemoryAttribute.Running);
|
||
Task.Run(async () =>
|
||
{
|
||
while (true)
|
||
{
|
||
try
|
||
{
|
||
if (shareMemory.ReadAttributeEqual(0, ShareMemoryAttribute.Closed))
|
||
{
|
||
shareMemory.RemoveAttribute(0, ShareMemoryAttribute.Running);
|
||
hook.Close();
|
||
Application.ExitThread();
|
||
Application.Exit();
|
||
Process.GetCurrentProcess().Kill();
|
||
}
|
||
}
|
||
catch (Exception)
|
||
{
|
||
}
|
||
await Task.Delay(1000);
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
private void OpenShareDesktop()
|
||
{
|
||
RDPSession session = new RDPSession();
|
||
session.OnAttendeeConnected += Session_OnAttendeeConnected;
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>湲<EFBFBD><E6B9B2>
|
||
session.Open();
|
||
|
||
IRDPSRAPIInvitation invitation = session.Invitations.CreateInvitation("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ", "<22>ҵĹ<D2B5><C4B9><EFBFBD><EFBFBD>Ự", "123", 1024);
|
||
string invitationString = invitation.ConnectionString;
|
||
|
||
Console.WriteLine("<22>뽫<EFBFBD><EBBDAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ṩ<EFBFBD><E1B9A9>Զ<EFBFBD>̿ͻ<CCBF><CDBB>ˣ<EFBFBD>");
|
||
Console.WriteLine(invitationString);
|
||
|
||
// <20>ȴ<EFBFBD><C8B4>رմ<D8B1><D5B4><EFBFBD>
|
||
Console.WriteLine("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>...");
|
||
Console.ReadKey();
|
||
|
||
session.Close();
|
||
}
|
||
private void Session_OnAttendeeConnected(object pAttendee)
|
||
{
|
||
IRDPSRAPIAttendee attendee = (IRDPSRAPIAttendee)pAttendee;
|
||
// <20><><EFBFBD>ÿͻ<C3BF><CDBB>˷<EFBFBD><CBB7><EFBFBD>Ȩ<EFBFBD><C8A8>Ϊ ViewOnly
|
||
attendee.ControlLevel = CTRL_LEVEL.CTRL_LEVEL_VIEW;
|
||
}
|
||
}
|
||
}
|