1-) C# - RDP ile masaüstü bağlantısı
0-) eğer uzak masaüstüne parolasız girmek istiyorsan bu linktekini yap
http://www.serhatakinci.com/index.php/uzak-masaustu-baglantisi-oturumlarinda-sifreyi-bos-gecmek.html
başlat – çalıştır – gpedit.msc--> windows ayarları->güvenlik ayarları->yerel ilkeler->güvenlik seçenekleri->
hesaplar: Yerel hesapların boş parola kullanımını sadece konsol oturumuyla sınırla -> seçenegine tıkla ve devre dışı bırak
1-) Windows form aplication oluştur ve asagıdakini yap
c#->toolbox->all windows forms-> sağ tık ->choose items->com components->Microsoft RDP Client Control (redistributable) - version 9 -> ok->
dedik sonra toolbox' a eklenicek oradan Microsoft RDP Client Control (redistributable) - version 9 seç ve forma ekle
2-) rdp-> properties->dock-> tam ekran yap
rdp-> properties->colordepth->32 yap
3-) RDP -> olaylar den şu 4 olayı ekle
OnConnecting(bağlanıyor),OnConnected(baglandi),OnDisconnected(bag kesildi),SizeChanged(boyutlandırma)
3.1-) Kütüphaneler
using MSTSCLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
3.2-) bunlarıda ekle class'ın altına
public partial class Form1 : Form
{
private CONNECTION_STATE constate = CONNECTION_STATE.DISCONNECTED;
public Form1()
{
InitializeComponent();
}
private enum CONNECTION_STATE//BAĞLANTI DURUMU
{
CONNECTED,//BAĞLANDI
CONNECTING,//BAĞLANIYOR
DISCONNECTED//BAĞLANTIYI KESMEK
}
}
4-) private void button1_Click(object sender, EventArgs e){//baglan buttonu
if (txt_ip.Text == "")
{
MessageBox.Show("İp boş geçilemez!!!");
return;
}
if (constate == CONNECTION_STATE.DISCONNECTED)//eğer bagli degilse
{
remote.Server = txt_ip.Text;
if (txt_user.Text.Contains(@"\") == true)//içerisinde \ işareti varsa
{
int ch = txt_user.Text.IndexOf(@"\");
remote.Domain = txt_user.Text.Substring(0, ch);// misal Domain\UserName --> buradaki Domain pc'nin adi --> UserName ise kullanicinin adı
remote.UserName = txt_user.Text.Substring(ch + 1);
//asağıdaki 2 satırı eger pc'nin şifresini biliyorsan direk giriş yapar
IMsTscNonScriptable secured = (IMsTscNonScriptable)remote.GetOcx();
secured.ClearTextPassword = "ramo0707";
Console.WriteLine("pc'nin adi = " + remote.Domain + "\npc'nin kullanici adi : " + remote.UserName);
}
else// \ işareti yoksa
{
remote.UserName = txt_user.Text;
}
remote.Connect();
}
else if (constate == CONNECTION_STATE.CONNECTED)//bağlıysa
{
remote.Disconnect();//çıkış yap :)
}
}
5-) //Tam ekran buttonunun içine yaz
if (constate==CONNECTION_STATE.CONNECTED)
{
remote.FullScreen = true;
remote.Reconnect((uint)remote.Size.Width, (uint)remote.Size.Height);//tam ekran denilebilir
}
6-)RDP'nin olayları
private void remote_OnConnecting(object sender, EventArgs e)
{
Text = "PC'ye bağlaıyor... --> " + txt_ip.Text;
constate = CONNECTION_STATE.CONNECTING;
}
private void remote_OnConnected(object sender, EventArgs e)
{
constate = CONNECTION_STATE.CONNECTED;
Text = "PC'ye bağlandı --> " + txt_ip.Text;
}
private void remote_OnDisconnected(object sender, AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEvent e)
{
constate = CONNECTION_STATE.DISCONNECTED;
Text = "Bağlantı Kesildi. --> " + txt_ip.Text;
}
private void remote_SizeChanged(object sender, EventArgs e)
{
try
{
remote.Reconnect((uint)remote.Size.Width,(uint)remote.Size.Height);//tam ekran denilebilir
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}