Autor Beitrag
Xeron
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP Home, Vista Home Premium 64Bit, Win7 Home Premium
Delphi 3 Prof, Delphi 7 Personal, Delphi 2010 Prof., AutoIt
BeitragVerfasst: Do 18.02.10 13:29 
Hi, ich habe ein großes Problem.
Ich habe ein Programm mit 2 Formularen.
In FOrmular soll man etwas eingeben und in Formular wird es wieder ausgegeben.

Ich weiß nicht wie das geht.
Form1.Edit1.text hab ich schon probiert. geht nicht.

Zurzeit mach ich es über ini Datein, da muss ich aber das Programm immer neu starten.

Wie umgehe ich das problem?


Unit 1
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
Adresse, Process: String;

...

ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'Setting.ini');
  Process := Edit1.Text;
  Adresse := Edit2.Text;
  ini.WriteString('Other', 'Process', Process);
  ini.WriteString('Other', 'Adress', Adresse);
  ini.UpdateFile;
  Form3.Show;
  ini.Free;


Unit2

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'Setting.ini');
  ini.UpdateFile;
  Process := ini.ReadString('Other', 'Process', '');
  Adresse := ini.ReadString('Other', 'Adress', '');
  ini.UpdateFile;
  ini.Free;

...

if ini.ReadBool('Save', 'Get', True) then
    Memo1.Lines.Add('  $PID = WinGetProcess(' + Process + ')')
  else
    Memo1.Lines.Add('  $PID = WinExists(' + Process + ')');


In der Unit2 unten sieht man die Variable "Process". Die Variable soll den gleichen Wert wie die aus Unit1 haben.

Wie geht das???
Memo1.Lines.Add('  $PID = WinGetProcess(' + Form1.Edit1.Text + ')') geht ja leider nicht

Danke :)


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Do 18.02.2010 um 23:38
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Do 18.02.10 13:34 
user profile iconXeron hat folgendes geschrieben Zum zitierten Posting springen:
Form1.Edit1.text hab ich schon probiert. geht nicht.
Oooh das 'geht nicht', verstehe, dann ist ja alles klar. Kleb einfach Beine dran und schreib dir einen Gleichgewicht-halte-algorithmus, dann lernt das bestimmt irgendwann Laufen, wenn du's ihm vormachst :zustimm:

Spaß beiseite: Eine kleine Fehlerbeschreibung wäre ganz nett gewesen ;)
Ich vermute, du hast in Unit2 die Unit1 nicht eingebunden. Die unit bindest du mit dem Schlüsselwort uses ein, aber wo genau man das nochmal hinschreibt :gruebel: Such mal nach Suche in: Delphi-Forum, Delphi-Library USES UNIT2, ich bin sicher, da findest du schnell ein Beispiel dafür. Danach müsste der Zugriff über Form1.Edit1.Text einwandfrei funktionieren.

Edit: Direkt unter das Schlüsselwort Implementation in Unit2 schreibst du uses Unit1; (Vorrausgesetzt es ist Unit2, in der du auf ein Element von Unit1 zugreifen willst)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Xeron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP Home, Vista Home Premium 64Bit, Win7 Home Premium
Delphi 3 Prof, Delphi 7 Personal, Delphi 2010 Prof., AutoIt
BeitragVerfasst: Do 18.02.10 16:31 
Hab ich:

zur vollstädnigkeit schreib ich mal den ganzen Code auf:

Unit 1

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:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
unit Memory;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, help, StdCtrls, inifiles, shellAPI,  Menus;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    GroupBox2: TGroupBox;
    Label3: TLabel;
    Label4: TLabel;
    Edit3: TEdit;
    GroupBox3: TGroupBox;
    Label5: TLabel;
    Label6: TLabel;
    Edit4: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Prozesslisteaufrufen1: TMenuItem;
    Beenden1: TMenuItem;
    Codeerzeugung1: TMenuItem;
    Optionen1: TMenuItem;
    N2: TMenuItem;
    AutoItCodeerzeugen1: TMenuItem;
    DelphiCOdeerzeugen1: TMenuItem;
    CCodeerzeugen1: TMenuItem;
    AddOnManager1: TMenuItem;
    AddOnhinzufgen1: TMenuItem;
    Hilfe1: TMenuItem;
    oDo1: TMenuItem;
    Info1: TMenuItem;
    Hilfe2: TMenuItem;
    wwwelitepvpersde1: TMenuItem;
    Button7: TButton;
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Beenden1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Prozesslisteaufrufen1Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure AutoItCodeerzeugen1Click(Sender: TObject);
    procedure Optionen1Click(Sender: TObject);
    procedure wwwelitepvpersde1Click(Sender: TObject);
    procedure Info1Click(Sender: TObject);
    procedure oDo1Click(Sender: TObject);
    procedure Hilfe2Click(Sender: TObject);
    procedure AddOnhinzufgen1Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    Adresse, Process: String;
  end;



var
  Form1: TForm1;
  ini: TINIFile;
  Adresse, Process: String;

implementation

uses Prozesslist, Code, optionen, Info, ToDo, Addon;

{$R *.dfm}

procedure TForm1.AddOnhinzufgen1Click(Sender: TObject);
begin
  Form7.Show;
end;

procedure TForm1.AutoItCodeerzeugen1Click(Sender: TObject);
begin
  ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'Setting.ini');
  Process := Edit1.Text;
  Adresse := Edit2.Text;
  ini.WriteString('Other', 'Process', Process);
  ini.WriteString('Other', 'Adress', Adresse);
  ini.Free;
  Form3.Show;
end;

procedure TForm1.Beenden1Click(Sender: TObject);
begin
  ShowMessage ('Und nicht den "Thanks" Button vergessen ;)');

  ini.Free;
  Application.Terminate;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'Setting.ini');
  ini.WriteString ('Memory', 'Write', (Edit4.Text));
  Run(ExtractFilePath(ParamStr(0))+'SoftRTVW.exe');
  ini.Free;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage ('Und nicht den "Thanks" Button vergessen ;)');

  ini.Free;
  Application.Terminate;
end;

procedure TForm1.Button3Click(Sender: TObject);
var Auslesen: String;
begin
  ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'Setting.ini');
  Process := Edit1.Text;
  Adresse := Edit2.Text;
  iniWrite (ExtractFilePath(ParamStr(0))+'Setting.ini', 'Memory', 'Process', Process);
  iniWrite (ExtractFilePath(ParamStr(0))+'Setting.ini', 'Memory', 'Adresse', Adresse);
  sleep(100);
  Run(ExtractFilePath(ParamStr(0))+'SoftRTV.exe');
  sleep(100);
  Label3.Caption := 'Aus Adresse: ' + Edit2.Text;
  Label5.Caption := 'In Adresse: ' + Edit2.Text;
  Auslesen := ini.ReadString('Value', 'Value', '');
  Edit3.Text := Auslesen;
  ini.Free;


end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'Setting.ini');
  Process := Edit1.Text;
  Adresse := Edit2.Text;
  ini.WriteString('Other', 'Process', Process);
  ini.WriteString('Other', 'Adress', Adresse);
  ini.UpdateFile;
  Form3.Show;
  ini.Free;
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
  Process := Edit1.Text;
  Adresse := Edit2.Text;
  ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'Setting.ini');
  ini.WriteString('Other', 'Process', Process);
  ini.WriteString('Other', 'Adress', Adresse);
  ini.Free;
  ini.UpdateFile;

end;

procedure TForm1.Hilfe2Click(Sender: TObject);
begin
  if MessageDlg ('Hilfe gibts im Forum. Jetzt öffnen?', mtconfirmation, [mbyes, mbno], 0) = mryes then
    ShellExecute(Application.Handle, 'open', 'www.elitepvpers.de', nil, nil, SW_SHOW);

end;

procedure TForm1.Info1Click(Sender: TObject);
begin
  Form5.Show;
end;

procedure TForm1.oDo1Click(Sender: TObject);
begin
  Form6.Show;
end;

procedure TForm1.Optionen1Click(Sender: TObject);
begin
  Form4.Show;
end;

procedure TForm1.Prozesslisteaufrufen1Click(Sender: TObject);
begin
  Form2.Show;
end;

procedure TForm1.wwwelitepvpersde1Click(Sender: TObject);
begin
  ShellExecute (Application.Handle, 'open', 'www.elitepvpers.de', nil, nil, SW_SHOW);
end;

end.


Und die Unit 2

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:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
unit Code;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, inifiles, StdCtrls, help,shellAPI, clipbrd,  Menus, ComCtrls;

type
  TForm3 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Memo1: TMemo;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Speichern1: TMenuItem;
    ffnen1: TMenuItem;
    N1: TMenuItem;
    Beenden1: TMenuItem;
    Button1: TButton;
    ListBox1: TListBox;
    OpenDialog2: TOpenDialog;
    procedure FormCreate(Sender: TObject);
    procedure Speichern1Click(Sender: TObject);
    procedure ffnen1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }

  end;

var
  Form3: TForm3;
  ini: TInIFile;
  Check: Boolean;



implementation

uses Memory, optionen;

{$R *.dfm}


procedure TForm3.Button1Click(Sender: TObject);
var Pfad: String;
    wnd: HWnd;
begin
  ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'SciTe.ini');
  if not FileExists ('SciTe.ini') then
  begin
    MessageDlg ('SciTe wurde nicht gefunden! Sie können es nun selbst suchen', mtinformation, [mbok, mbcancel], 0);
    OpenDialog2.Execute();
    Pfad := OpenDialog2.FileName;
    ini.WriteString('SciTe', 'Pfad', Pfad);
    Run (Pfad);
  end;
    if FileExists ('SciTe.ini') then
    begin
    Pfad := ini.ReadString('SciTe', 'Pfad', '');
    ShellExecute(Application.Handle, 'open', PChar(Pfad), nil, nil, SW_SHOW);
    end;

    Memo1.SelectAll;
    Memo1.CopyToClipboard;
    sleep(300);

    wnd := FindWindow ('SciTEWindow', nil);
    if wnd <> 0 then
    begin
      SetForeGroundWindow(wnd);
      keybd_event(VK_CONTROL, 0, 0, 0);
      keybd_event(Ord('V'), 0,0,0);
    end
    else
      MessageDlg ('Es wurde ein Fehler festgestellt.', mterror, [mbok], 0);
end;





procedure TForm3.ffnen1Click(Sender: TObject);
begin
  OpenDialog1.Execute();
  Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
  ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'Setting.ini');
  ini.UpdateFile;
  Process := ini.ReadString('Other', 'Process', '');
  Adresse := ini.ReadString('Other', 'Adress', '');
  ini.UpdateFile;
  ini.Free;

  ini := TInIFile.Create(ExtractFilePath(ParamStr(0))+'Save.ini');
  Memo1.Lines.Add('#cs' +#13#10+'--------------------------------------------------------' +#13#10+
                  'Dieser Code wurde von General Desert / Markus erzeugt ' + #13#10 +
                  '----------------------------------------------------------' + #13#10 + '#ce'
                  +#13#10 + #13#10   +
                  '#include <NomadMemory.au3>');
  if ini.ReadBool('Save', 'Admin', True) then
    Memo1.Lines.Add('#RequireAdmin');
  if ini.ReadBool('Save', 'Admin', False) then
    Memo1.Lines.Add(#13#10);

  if ini.ReadBool ('Save', 'Privi', True) then
    Memo1.Lines.Add('SetPrivilege("SedDebugPrivilege", 1)');



  if ini.ReadBool('Save', 'Get', True) then
    Memo1.Lines.Add('  $PID = WinGetProcess(' + Process + ')')
  else
    Memo1.Lines.Add('  $PID = WinExists(' + Process + ')');

  if ini.ReadBool ('Save', 'Prozess', True) then
    Memo1.Lines.Add(#13#10 + 'if $PID = 0 then' + #13#10 + '  MsgBox(16, "Fehler", "Prozess nicht gefunden!")'
                    + #13#10 + 'Exit' + #13#10 + 'EndIf'  + #13#10)
  else
    Memo1.Lines.Add(#13#10);

  //=============================================================================================================

    if ini.ReadBool ('Save', 'Schleife', True) then
    begin

    Memo1.Lines.Add('$Open = _MemoryOpen($PID)' + #13#10 + 'Dim $Read = 0' + #13#10 +  'While 1' + #13#10
                    + '  $Read = _MemoryRead ('+ Adresse + ', ' + Process +')' + #13#10 + '  if $Read <> $Read then');
    Memo1.Lines.Add('  ;Deine Anweisung' +#13#10 + '$Read = $Read' + #13#10 + 'WEnd');
    end
  else
  begin
   Memo1.Lines.Add('  $Open = _MemoryOpen($PID)' + #13#10 + '  $Read = _MemoryRead ('+ Adresse + ', '
                  + Process + ')' + #13#10);
 end;

 //================================================================================================================

 ini.Free;
 end;

procedure TForm3.Speichern1Click(Sender: TObject);
begin
  SaveDialog1.Execute();
  Memo1.Lines.SaveToFile(SaveDialog1.Filename + '.txt');
end;

end.



Im Anhang ist nochmal ein Miniprogramm zum Verdeutlichen.

€ Auch ein Aufruf wie "unit1.Form1.Edit1.Text" oder "Form1.Test" (Test ist eine Variable im Public Verzeichnis) bringt nix.
Einloggen, um Attachments anzusehen!
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Do 18.02.10 17:12 
Und "bringt nix" ist die Fehlermeldung, die Delphi anzeigt?

_________________
PROGRAMMER: A device for converting coffee into software.
Xeron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP Home, Vista Home Premium 64Bit, Win7 Home Premium
Delphi 3 Prof, Delphi 7 Personal, Delphi 2010 Prof., AutoIt
BeitragVerfasst: Do 18.02.10 17:18 
es gibt keine fehlermeldung.
Alles wird ohne Anstand übersetzt.
Nur man sieht nix.
Dude566
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Do 18.02.10 17:33 
Bei deinem letzten Code hast du in Unit2 ja auch immer noch nicht Unit1 in die Uses eingetragen. :roll:

_________________
Es gibt 10 Gruppen von Menschen: diejenigen, die das Binärsystem verstehen, und die anderen.
Xeron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP Home, Vista Home Premium 64Bit, Win7 Home Premium
Delphi 3 Prof, Delphi 7 Personal, Delphi 2010 Prof., AutoIt
BeitragVerfasst: Do 18.02.10 17:36 
Wo den? Bin ich blind?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
implementation

uses Memory, optionen;

{$R *.dfm}




ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
implementation

uses Prozesslist, Code, optionen, Info, ToDo, Addon;

{$R *.dfm}
Xeron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP Home, Vista Home Premium 64Bit, Win7 Home Premium
Delphi 3 Prof, Delphi 7 Personal, Delphi 2010 Prof., AutoIt
BeitragVerfasst: Do 18.02.10 18:31 
Ok, Problem gelöst.

Grund war, das ich die Routine in das Form.Create Ereignis gesteckt habe