unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, ComCtrls;
type
TForm1 = class(TForm)
IdTCPClient1: TIdTCPClient;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
StatusBar1: TStatusBar;
procedure FormCreate(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure IdTCPClient1Disconnected(Sender: TObject);
procedure Button12Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
procedure TForm1.FormCreate(Sender: TObject);
//Bağlantı Ayarları
begin
Edit1.Text:='162.168.1.1';
Edit2.Text:='20000';
IdTCPClient1.Host:=Edit1.Text;
IdTCPClient1.Port:=StrToInt(Edit2.Text);
Button12.Enabled:=False;
end;
procedure TForm1.Button11Click(Sender: TObject);
//Bağlan
var
oku:AnsiString;
begin
IdTCPClient1.Connect();
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[0].Text:=oku;
Button11.Enabled:=False;
Button12.Enabled:=True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('notepad');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('cdac');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('cdkapat');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('ekran');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
var
oku:AnsiString;
mesaj:AnsiString;
begin
mesaj:=InputBox('Mesajı Giriniz','Mesaj','Selam');
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('mesaj');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('sil');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button7Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('kopyala');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('elips');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button9Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('comboac');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.Button10Click(Sender: TObject);
var
oku:AnsiString;
begin
if IdTCPClient1.Connected then
begin
IdTCPClient1.WriteLn('kapat');
oku:=IdTCPClient1.ReadLn;
StatusBar1.Panels[1].Text:=oku;
end;
end;
procedure TForm1.IdTCPClient1Disconnected(Sender: TObject);
begin
StatusBar1.Panels[0].Text:='Bağlantı Kesildi';
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
IdTCPClient1.Disconnect;
Button12.Enabled:=False;
Button11.Enabled:=True;
end;
end.
Server Kodları:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, IdBaseComponent, IdComponent, IdTCPServer, MMSYSTEM;
type
TForm1 = class(TForm)
IdTCPServer1: TIdTCPServer;
Label1: TLabel;
ComboBox1: TComboBox;
StatusBar1: TStatusBar;
procedure IdTCPServer1Connect(AThread: TIdPeerThread);
procedure FormCreate(Sender: TObject);
procedure IdTCPServer1Execute(AThread: TIdPeerThread);
private
public
end;
var
Form1: TForm1;
implementation
procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread);
begin
AThread.Connection.WriteLn('Bağlantı Sağlandı');
StatusBar1.Panels[0].Text:='Komut Bekleniyor';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
IdTCPServer1.DefaultPort:=20000;
IdTCPServer1.Active:=True
end;
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
mesaj:AnsiString;
i:Integer;
ad:Array[0..5] of PAnsiChar;
elips:HRGN;
begin
mesaj:=AThread.Connection.ReadLn;
if mesaj='notepad' then
begin
WinExec('c:winntnotepoad.exe',SW_SHOW);
AThread.Connection.WriteLn('Şuan Server da NotePad Calışıyor');
StatusBar1.Panels[1].Text:='En Son Calıştır Komutu Geldi';
end
else if mesaj='cdac' then
begin
mciSendString('set cdaudio door open',nil,0,0); //kapagı ac
AThread.Connection.WriteLn('Cd Kapağı Acıldı');
StatusBar1.Panels[1].Text:='En Son Cd Kapağını Ac Komutu Geldi';
end
else if mesaj='cdkapat' then
begin
mciSendString('set cdaudio door closed',nil,0,0); //kapagı kapat
AThread.Connection.WriteLn('Cd Kapağı Kapatıldı');
StatusBar1.Panels[1].Text:='En Son Cd Kapağını Kapat Komutu Geldi';
end
else if mesaj='ekran' then
begin
SendMessage(Application.Handle,WM_SYSCOMMAND,SC_SC REENSAVE,0);
AThread.Connection.WriteLn('Ekran Koruyucu Acıldı');
StatusBar1.Panels[1].Text:='En Son Ekran Koruyucu Calıştır Komutu Geldi';
end
else if mesaj='sil' then
begin
DeleteFile('Chaha.txt');
AThread.Connection.WriteLn('Dosya Silindi');
StatusBar1.Panels[1].Text:='En Son Dosya Sil Komutu Geldi';
end
else if mesaj='kopyala' then
begin
for i:=0 to 5 do //Altı kere kopyala
begin
StrPCopy(ad[0],PCHar(IntToStr(1))); //Yeni isimler
CopyFile('c:haha.txt',PCHar('C:haha'+Ad[0]+'.txt'),FALSE);
//Kendime not

end;
AThread.Connection.WriteLn('Dosya Kopyalandı');
StatusBar1.Panels[1].Text:='En Son Dosya Kopyala Komutu Geldi';
end
else if mesaj='elips' then
begin
elips:=CreateEllipticRgn(0,0,Form1.Width,Form1.Hei ght);
SetWindowRgn(Form1.Handle,elips,true);
AThread.Connection.WriteLn('Form Elips Şeklinde');
StatusBar1.Panels[1].Text:='En Son Formu Elips Yap Komutu Geldi';
end
else if mesaj='comboac' then
begin
SendMessage(ComboBox1.Handle,CB_SHOWDROPDOWN,200,0 );
AThread.Connection.WriteLn('ComboBox Acıldı');
StatusBar1.Panels[1].Text:='En Son ComboBox ı Ac Komutu Geldi';
end
else if mesaj='kapat' then
begin
ExitWindows(12,ewx_logoff);
AThread.Connection.WriteLn('Kapanıyor');
StatusBar1.Panels[1].Text:='En Son Kapat Komutu Geldi';
end
else
begin
ShowMessage(mesaj);
AThread.Connection.WriteLn('Mesaj Alındı');
StatusBar1.Panels[1].Text:='Mesaj Geldi';
end;
end;
end.
ama ne zaman Clienti acıp Server'a baglanmayı denesem Socket Error 10060 Bagğlantı zaman asımına ugradı hatasını alıyorum neden kaynaklanıyor olabilir yardımlarınız icin simdiden tesekkurler
__________________