Autor Beitrag
hpburner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: So 09.02.03 01:56 
Hallo

ich möchte das beim Button.Onclick (also wen ich ne Button drücke...) ein externes Programm ausgeführt wird. Pfad und dateiname soll über die Ini Datei ausgelesen werden wie stell ich das an ?! (bekomme einfach nicht hin...) So sieht das bei mir nun aus
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure TmainForm.Button1Click(Sender: TObject);
var ini : TInifile; Programm1 : String;
begin
Programm1:=Ini.ReadString('Button1','Run','');
ShellExecute(Handle, 'open', Ini.ReadString('Button1','Run',''), nil, nil, SW_SHOWNORMAL);
end;


läuft natürlich überhaupt nicht ;) wäre nett wenn mir das mal einer korrigieren könnte habe leider nciht genug ahnung :(

Moderiert von user profile iconTino: Code-Tags hinzugefügt.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: So 09.02.03 02:27 
Hi und Willkommen im Forum!

wo gibst Du eigentlich an aus welcher INI-Datei der Eintrag gelesen werden soll? Außerdem musst Du die INI Variable initialisieren. Dadurch wird dann auch der Dateiname angegeben:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Var
  Ini: tIniFile;
  Programm1: String;
Begin
  Ini := tIniFile.Create ('c:\test.ini');
  Programm1 := Ini.ReadString ('Button1', 'Run', '');

  If Programm1 <> '' Then
    ShellExecute (Handle, 'open', pChar (Programm1), nil, nil, SW_SHOWNORMAL);

  Ini.Free;
End;

Gruß
TINO
hpburner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: So 09.02.03 21:33 
danke dir !
hat soweit alles geklappt
spitzen forum ;)