Autor Beitrag
Death666Metal
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 22

Win XP
Delphi 7/html/php/flash/basic/c++
BeitragVerfasst: Di 18.10.05 21:03 
Wie schreibe ich, dass automatisch mit dem öffnen der .exe dann eine Datei (bei mir: music.wpl) geöffnet wird und die .exe dann sich selbst schließt?
Hab die Version nur mit Button

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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, ShellAPI, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
   
    procedure Button1Click(Sender: TObject);


  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(Application.Handle, 'open', 'C:\My Musik.wpl', nil, nil, SW_SHOW);
close;
end;

end.


Und wie schreibe ich nun, dass das was durch den Button ausgelöst wird auto mit dem Öffnen ausgelöst wird?
Danke!
Grishnak
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 221

Windows XP Home
Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Di 18.10.05 21:11 
Schreib die Anweisung in "Form.OnCreate"

_________________
Mach' etwas idiotensicher und irgendjemand erfindet einen besseren Idioten!
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Di 18.10.05 21:53 
wenn die Exe sich selbst sofort wieder selbst schließt geht es auch einfacher:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
program Test;
uses Windows, ShellAPI; // weiß nicht, welche noch benötigt werden, da ungetestet (evtl. messages)

begin
 ShellExecute(0, 'open', 'C:\My Musik.wpl', nil, nil, SW_SHOW);
end.

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Death666Metal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 22

Win XP
Delphi 7/html/php/flash/basic/c++
BeitragVerfasst: Mi 19.10.05 17:25 
user profile iconGSE hat folgendes geschrieben:
wenn die Exe sich selbst sofort wieder selbst schließt geht es auch einfacher:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
program Test;
uses Windows, ShellAPI; // weiß nicht, welche noch benötigt werden, da ungetestet (evtl. messages)

begin
 ShellExecute(0, 'open', 'C:\My Musik.wpl', nil, nil, SW_SHOW);
end.

Das als Programm funktioniert nich, was sollichn da schreibn?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Mi 19.10.05 22:34 
das Programm funktioniert schon, du musst es bloß in
deine DPR Datei schreiben. Du kannst dann alle Forms aus dem Projekt entfernen,
da sie nicht benötigt werden.

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Death666Metal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 22

Win XP
Delphi 7/html/php/flash/basic/c++
BeitragVerfasst: Do 20.10.05 10:39 
Versteh ich nich.
Das was dort steht sollich in der Unit1 eintragen oder?
Und was kommt dann in die dpr?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Do 20.10.05 17:29 
nein, unit1 kannst du aus dem Projekt entfernen
und "das was dort steht" kommt so in die dpr (Delphi-Project),
da die dpr ja eigentlich dein Haupt-Programmkonstrukt enthält, das
dafür sorgt, dass die anderen Teile geladen werden.
(d.h. dein programm besteht dann nur aus der dpr Datei mit diesem Inhalt, keine weiteren Units oder Forms)
Hoffe, das war jetzt besser formuliert. :wink:

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Death666Metal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 22

Win XP
Delphi 7/html/php/flash/basic/c++
BeitragVerfasst: Fr 21.10.05 20:30 
Das war verständlich, danke!!!
:beer:
Wie gesagt bin noch absoluter Anfänger und das was wir in der Schule machn hilft mir bei solchen Sachen nicht, da die "Lehrer" (wenn man die so bezeichnen kann) nur das können was das Buch vorsieht.
Also Danke!!! :flehan: