Autor Beitrag
Default112
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP
D6 Prof
BeitragVerfasst: So 20.06.04 14:04 
Ich habe 2 Programme geschrieben, jetzt soll das eine Programm einen String an das andere senden. Wie kann ich den String senden bzw. empfangen?

Thx
Gruss
Def
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 20.06.04 14:13 
Hallo da gibt es mehrere Möglichkeiten. Die einfachste sind Windowsmessages. Schau dir mal Suche in: Delphi-Forum, Delphi-Library WM_COPYDATA an.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Default112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP
D6 Prof
BeitragVerfasst: So 20.06.04 15:43 
Klasse :D Für die, die es Interessiert: www.swissdelphicente.../showcode.php?id=810

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:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
// Sender: Send data
// Sender: Daten schicken

procedure TForm1.Button1Click(Sender: TObject);
var
  aCopyData: TCopyDataStruct;
  hTargetWnd: HWND;
begin
  with aCopyData do
  begin
    dwData := 0;
    cbData := StrLen(PChar(Edit1.Text)) + 1;
    lpData := PChar(Edit1.Text)
  end;
  // Search window by the window title
  // Fenster anhand des Titelzeilentext suchen
  hTargetWnd := FindWindowEx(0, 0, nil, PChar('WM_COPYDATA-Receiver'));
  if hTargetWnd <> 0 then
    SendMessage(hTargetWnd, WM_COPYDATA, Longint(Handle), Longint(@aCopyData))
  else
    ShowMessage('No Recipient found!');
end;


(* -------------------------------------------------------------------- *)


// Recipient - Receive data
// Empfänger - Daten empfangen

type
  TForm1 = class(TForm)
    private
    { Private declarations }
    procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
  public
    { Public declarations }
  end;

procedure TForm1.WMCopyData(var Msg: TWMCopyData);
var
  sText: array[0..99] of Char;
begin
  // generate text from parameter
  // anzuzeigenden Text aus den Parametern generieren
  StrLCopy(sText, Msg.CopyDataStruct.lpData, Msg.CopyDataStruct.cbData);
  // write received text
  // Empfangenen Text ausgeben
  label1.Caption := sText;
end;
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Mo 21.06.04 08:49 
Weit gesucht. Dabei gibt es auch hier im Forum ein FAQ Beitrag:

www.delphi-forum.de/viewtopic.php?t=7866

Warum nur :roll:

_________________
Gruß
Martin