Autor Beitrag
ex4ct
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mo 10.04.06 18:09 
Hallo an alle!
Dies ist mein erster Beitrag hier im Forum.
Ich habe ein Client/Server(Remote Administration Tool) programmiert.
Da sind paar Funktionen wie CD-ROM Laufwerk öffnen und schliessen oder Sound abspielen u.a.!
Jetzt wollte ich eine Funktion hinzufügen, mit dem ich eine Internetseite aufrufen lassen kann.
Ich habe es mit(server):
ausblenden Delphi-Quelltext
1:
2:
else if MyString ='InternetadresseAufrufen' then 
begin StrPCopy(TMP, edit3.text); ShellExecute(0,NIL,TMP,NIL,NIL,SW_Normal); end;

Das,üsste eigentlich so gehen aber da ich
"edit3.text"(die eingegebene URL) nur mein Client kennt, kann die Server.exe damit nichts anfangen.
Wie kann ich dem Server sagen dass edit3.text die eingegebene URL bei dem Client ist? Übrigens "MyString" ist(server):
ausblenden Delphi-Quelltext
1:
myString := Socket.ReceiveText;					

Der Befehl was welches Wort MyString hat ist das(client):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button40Click(Sender: TObject);
begin
ClientSocket1.Socket.SendText('InternetadresseAufrufen');
end;

MFG!
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 18:16 
Wenn ich das richtig verstanden habe, dann weiß der Server die Adresse nicht?
Dann musst du sie im String mitsenden.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Mo 10.04.06 18:17 
Send doch beim Befehl Internetadresseausführn ( oder wie der heißt ) noch die URL mit.
Das sähe dann so aus ( ungetestet )
ausblenden Delphi-Quelltext
1:
2:
3:
4:
If Copy(MyStr,1,Pos(':',Mystr))='Internetadresseausführen' Then begin
   Delete(myStr,0,Pos(':',Mystr));
   // In my Str ist dann nur noch die URL
end;

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mo 10.04.06 18:22 
fangen strings net bei 1 an ?
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Mo 10.04.06 18:25 
Bei Copy schon

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mo 10.04.06 18:35 
Hmm..kann ich nicht wie bei "myString := Socket.ReceiveText;" einfach "edit3.text :=Socket.ReceiveText2;" oder so machen?
Sorry bin relativ neu, aber arbeite fleissig:-D

www.faqsen.de/delphi...48544850495748535249


Zuletzt bearbeitet von ex4ct am Mo 10.04.06 18:38, insgesamt 1-mal bearbeitet
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 18:38 
Liegt edit3 in der Client oder der Serverapplikation?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mo 10.04.06 18:39 
user profile iconMarco D. hat folgendes geschrieben:
Liegt edit3 in der Client oder der Serverapplikation?

In der Client-Applikation! :-)
Will ja die URL selber eingeben^^
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 18:46 
Na dann so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
//Client
clientsocket1.socket.sendtext('InternetAdressenAufrufen#'+edit3.text);
//Server
var url,s:string;
s:=socket.receivetext;
for i := pos('#',s) to length(s) do
begin
  url:=url+s[i];
end;
//Ausgabe:
showmessage(url);

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mo 10.04.06 18:49 
Vielen Dank Marco, werde ich gleich probieren !!
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Mo 10.04.06 19:07 
@Marco ist das nicht das selbe, was ich ihm geschickt habe?, nur das ich ihm gleich den Einabu in sein Script ermöglicht habe?

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mo 10.04.06 19:16 
Es geht leider nicht!

Server:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
myString,url,s: String;
buff : array[0..MAX_COMPUTERNAME_LENGTH] of char;
TMP: Array[0..255of char;
nsize : DWORD;
rc : hwnd;
i:integer;
begin
nsize := SizeOf(buff);
myString := Socket.ReceiveText;
s:=socket.receivetext;
Randomize();
if      MyString = 'CDRomOeffnen'          then mciSendString('Set cdaudio door open wait'nil0, handle)
else if MyString = 'CDRomSchliessen'       then mciSendString('Set cdaudio door closed wait'nil0, handle)
else if MyString = 'Neustarten'            then ExitWindowsEx(EWX_REBOOT,0)
else if MyString = 'Herunterfahren'        then ExitWindowsEx(EWX_SHUTDOWN,0)
else if MyString = 'BenutzerAbmelden'      then ExitWindowsEx(EWX_LOGOFF,0)
else if MyString = 'schnellHerunterfahren' then ExitWindowsEx(EWX_FORCE,0)
else if MyString = 'StrgAltEnfFreigeben'   then SystemParametersInfo(SPI_SCREENSAVERRUNNING,0,0,0)
else if MyString = 'StrgAltEnfSperren'     then SystemParametersInfo(SPI_SCREENSAVERRUNNING,1,0,0)
else if MyString = 'MonitorStandby'        then SendMessage(Application.Handle, wm_SysCommand, SC_MonitorPower, 0)
else if MyString = 'MauspositionAendern'   then SetCursorPos(Random(800),Random(600))
else if MyString = 'StartbuttonLoeschen'   then begin rc := FindWindow('Shell_traywnd',nil); ShowWindow(FindWindowEx(rc,0,'Button',nil),0); end
else if MyString = 'StartbuttonZeigen'     then begin rc := FindWindow('Shell_traywnd',nil); ShowWindow(FindWindowEx(rc,0,'Button',nil),1); end
else if MyString = 'TaskbarVerstecken'     then ShowWindow(FindWindow('shell_traywnd',nil),0)
else if MyString = 'TaskbarZeigen'         then ShowWindow(FindWindow('shell_traywnd',nil),1)
else if MyString = 'Computername'          then begin GetComputerName(Pchar(@buff),nsize); Socket.SendText(buff); end

else if MyString ='InternetAdressenAufrufen#'then
begin
for i := pos('#',s) to length(s) do
begin
  url:=url+s[i];
end;
shellexecute(handle,'open',url,nil,nil,sw_show); end;


CLIENT:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button40Click(Sender: TObject);
begin
clientsocket1.socket.sendtext('InternetAdressenAufrufen#'+edit3.text);
end;
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Mo 10.04.06 19:32 
Wie gesagt mein Skript kannst du genauso Implementieren.
Was du jetzt machst ist witzlos. Der String hört nicht mit # auf!
Du musst es machen wei ich geschrieben habe.
:autsch: :autsch: :autsch:

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 10.04.06 20:09 
Moin!

Schau dir mal dieses Tut hier an, damit solltest du dein Problem lösen können. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 10.04.06 20:17 
user profile iconFighter#1 hat folgendes geschrieben:
Wie gesagt mein Skript kannst du genauso Implementieren.
Was du jetzt machst ist witzlos. Der String hört nicht mit # auf!
Du musst es machen wei ich geschrieben habe.
:autsch: :autsch: :autsch:

Ich habe jetzt eine allgemeine Lösung angegeben. Und da der Threadersteller darauf nicht wirklich eingegangen ist, habe ich das ganze neu geschrieben. Es ging mir dabei nur um das Funktionsprinzip, nicht auf diesen speziellen Fall ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Mo 10.04.06 20:41 
user profile iconex4ct hat folgendes geschrieben:

Sorry bin relativ neu, aber arbeite fleissig:-D

Er schreibt, dass er neuling ist.
Da kann man ihm doch gleich ein bisschen entgegen kommen und ihm damit helfen.
So erleichtern wir ihm den Einstieg in Delphi, und wenns klappt machts nochmehr spaß.

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mo 10.04.06 20:44 
Ich kenne mich mit TurboPascal aus aber Delphi macht mir mehr Spaß auch wenn ich noch viel lernen muss!:)
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mo 10.04.06 21:59 
Habe leider immernoch Probleme!

Client:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button40Click(Sender: TObject);
begin
clientsocket1.socket.sendtext('aufrufen' + edit3.text);
end;


Wie soll ich das beim server machen, dass es auf 'aufrufen' + edit3.text reagiert?
Normalerweise hatte ich das so gemacht:

ausblenden Delphi-Quelltext
1:
2:
if      MyString = 'CDRomOeffnen'          then mciSendString('Set cdaudio door open wait'nil0, handle)
else if MyString = 'CDRomSchliessen'       then mciSendString('Set cdaudio door closed wait'nil0, handle)


aber für ('aufrufen' + edit3.text) kann ich das nicht machen :S
So gehts nicht:

ausblenden Delphi-Quelltext
1:
else if MyString = 'aufrufen '+edit3.text then .......					


Der Server weis ja nicht was Edit3.text ist der hat nur MyString und das ist dann :
"aufrufen http://beispiel.de"

Bitte helft mir!:(
Balmung der blaue Gott
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 52

WinXP

BeitragVerfasst: Mo 10.04.06 22:46 
Hallo,

Ich nehme an, du hast nicht verstanden, was in den vorherigen postings geschrieben wurde, also nochmal mit Erläuterung:
Statt if MyString = 'aufrufen '+edit3.text then .......
nimmst du If Copy(MyString,1,10)='aufrufen ' Then .......
Copy(MyString,1,10) sind die ersten 10 Zeichen von MyString und wenn die gleich 'aufrufen ' sind, dann ist der Rest die Internetadresse. Diese steht nach dem Befehl Delete(MyStr,0,10); in MyString, weil damit die ersten 9 Zeichen gelöscht werden.
Das heißt, du kannst jetzt mit ShellExecute(0,NIL,TMP,NIL,NIL,SW_Normal); die Internetadresse aufrufen!

Das ist zwar nicht die eleganteste Lösung, aber vielleicht besser verständlich.

Leider hab ich die Befehle Copy und Delete nicht in der Hilfe gefunden (warumauchimmer). Du kannst ja jenachdem, ob ein Leerzeichen Zeichen zuvielin der aufgerufenen Adressesteht oder ein Zeichen zu wenig, mehr oder weniger Zeichen löschen oder falls es nicht funktioniert auch Kopieren.

_________________
Leben und sterben lassen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 10.04.06 23:06 
Moin!

user profile iconex4ct hat folgendes geschrieben:
Habe leider immernoch Probleme!
[...]
Bitte helft mir!:(

Sorry, aber dein Ansatz für ein Protokoll ist nicht wirklich gut geeignet. Schau dir doch mal das Tutorial an, da wird dir praktisch die Lösung in kleinen Häppchen präsentiert. ;) Wenn du ein Protokoll brauchbar umsetzen kannst, dann ist das Senden einer Variablen ein Kinderspiel. :D

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.