What you'll need:
A host application, and a viewer application
The host:
- Add reference, rdpcomapi 1.0 Type Library.
- Add using RDPCOMAPILib;
- Add this method
private
void Incoming(object
Guest)
{
IRDPSRAPIAttendee
MyGuest = (IRDPSRAPIAttendee)Guest;//???
MyGuest.ControlLevel = CTRL_LEVEL.CTRL_LEVEL_INTERACTIVE;
}
- Add this class level variable
RDPSession x = new RDPSession();
Create three new buttons, and a textbox(dont rename the controls, make use of their default names)
Code:
First button:
private void
button1_Click(object sender, EventArgs e)
{
x.OnAttendeeConnected += Incoming;
x.Open();
}
Second button:
private void button2_Click(object sender, EventArgs
e)
{
IRDPSRAPIInvitation Invitation = x.Invitations.CreateInvitation("Trial",
"MyGroup", "", 10);
textBox1.Text =
Invitation.ConnectionString;
}
Third button:
private void
button3_Click(object sender, EventArgs e)
{
x.Close();
x = null;
}
The viewer:
- Right click on toolbox and click Choose items...
- In the dialog under COM components, check RDPViewer Class, and click OK
- Drag and Drop RDPViewer object onto form.
Create two new buttons, and a textbox.
Code:
First button:
private void
button1_Click(object sender, EventArgs e)
{
string Invitation = textBox1.Text;//
"";// Interaction.InputBox("Insert Invitation
ConnectionString", "Attention");
axRDPViewer1.Connect(Invitation, "User1", "");
}
Second button:
private void
button2_Click(object sender, EventArgs e)
{
axRDPViewer1.Disconnect();
}
How to use:
- On host click button one, the start button
- On host click button two, the get invite button
- On host copy the text in the text box
- On viewer paste into text box
- On viewer click button one, the connect button
- To end click the finish button on either side
Full source code:
The viewer:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ScrS_viewer_
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void button1_Click(object
sender, EventArgs e)
{
string
Invitation = textBox1.Text;// "";// Interaction.InputBox("Insert
Invitation ConnectionString", "Attention");
axRDPViewer1.Connect(Invitation, "User1", "");
}
private
void button2_Click(object
sender, EventArgs e)
{
axRDPViewer1.Disconnect();
}
private
void Form1_Load(object
sender, EventArgs e)
{
panel1.Height = Screen.PrimaryScreen.Bounds.Height - 100;
}
}
}
The host:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using RDPCOMAPILib;
namespace ScrS_server_
{
public partial class Form1 : Form
{
RDPSession
x = new RDPSession();
public
Form1()
{
InitializeComponent();
}
private
void Form1_Load(object
sender, EventArgs e)
{
}
private
void Incoming(object
Guest)
{
IRDPSRAPIAttendee
MyGuest = (IRDPSRAPIAttendee)Guest;//???
MyGuest.ControlLevel = CTRL_LEVEL.CTRL_LEVEL_INTERACTIVE;
}
private
void button1_Click(object
sender, EventArgs e)
{
x.OnAttendeeConnected += Incoming;
x.Open();
}
private
void button2_Click(object
sender, EventArgs e)
{
IRDPSRAPIInvitation
Invitation = x.Invitations.CreateInvitation("Trial",
"MyGroup", "", 10);
textBox1.Text =
Invitation.ConnectionString;
}
private
void button3_Click(object
sender, EventArgs e)
{
x.Close();
x = null;
}
}
}