Autor Beitrag
kulka1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 06.06.09 10:46 
Hallo, alles fit? :P

ich habe ein programm geschrieben und dazu habe ich eine frage, und zwar möchte ich gerne, das wenn ich an meinem programm etwas verändere, bespiel n button oder so dazufüge, das sich das dann beim starten meines programm bei anderen pc's (benutzern) automatisch übernimmt.

wisst ihr was ich meine?

mfg kulka1
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 06.06.09 10:54 
Das nennt sich Update und ist nicht so einfach. Dafür musst du das Update auf einen Server legen und die Programme müssen dort jeweils nachschauen. Das Problem ist bei fest installierten Programmen dann auch, dass die Rechte fehlen, so dass ein Ersetzen nicht direkt geht usw.

Ich bin gerade dabei ein Framework für eine Updatefunktion zu schreiben.

Die Frage ist aber erst einmal: Hast du einen Server / Webspace über den das Update laufen kann?
kulka1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 06.06.09 10:57 
jap, ich habe einen server gekauft, wenn das deine frage beantworten würde ;), ne seite hab ich auch
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 06.06.09 10:59 
Dann kannst du im einfachsten Fall, wenn dein Programm nicht installiert wird, sondern portabel ist, einfach beim Start nachschauen ob eine neue Version da ist.
Wenn ja, lädst du die herunter, benennst deine laufende Exe um und ersetzt die und startest dann die neue Exe mit einem Parameter, der der sagt, dass es die alte Exe löschen soll.
kulka1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 06.06.09 11:06 
das mit dem herunterladen wüsste ich ja wie das geht ;),

aber wie mache ich das hier:

Zitat:
Wenn ja, lädst du die herunter, benennst deine laufende Exe um und ersetzt die und startest dann die neue Exe mit einem Parameter, der der sagt, dass es die alte Exe löschen soll.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 06.06.09 11:12 
Im Grunde einfach so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  DownloadedFile: TMemoryStream;
  MyIdHttp: TIdHttp;
begin
...
  RenameFile(ParamStr(0), ChangeFileExt(ParamStr(0), '.exe.bak'));
  MyIdHttp.Get('http://...', DownloadedFile);
  DownloadedFile.SaveToFile(ParamStr(0));
  ShellExecute(Handle, 'open', PChar(ParamStr(0)), 
    PChar('/delete "' + ChangeFileExt(ParamStr(0), '.exe.bak') + '"'), '', SW_SHOWNORMAL);
Beim Start musst du nach dem Parameter /delete Ausschau halten und ggf. die entsprechende Datei löschen.

Wichtig: Das funktioniert wie gesagt nicht, wenn das Programm installiert wird. Denn dann liegt es unter c:\Programme, wo du normalerweise keine Schreibrechte hast.
kulka1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 06.06.09 11:16 
okay, danke für den code, muss da denn garkein pfad eingegeben werden?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 06.06.09 11:36 
Habe ich doch... :gruebel:
ParamStr(0) ist doch der Dateiname inkl. Pfad.
kulka1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 06.06.09 11:50 
ah stimmt hast recht, ich muss .exe.bak überall noch den richtigen namen vom programm vorschreiben oder?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 06.06.09 11:53 
Nein, wozu? Das macht den temporären Dateinamen doch unnötig lang, wenn der Dateiname ohne Endung doppelt vorkommt. Du solltest dir vielleicht einmal überlegen was ChangeFileExt macht (schon rein vom Namen her). ;-)
kulka1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 06.06.09 12:09 
okay... muss ich den Code ganz am anfang hintun? vorallem anderen?
hab das jetzt so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  DownloadedFile: TMemoryStream;
  MyIdHttp: TIdHttp;
begin
   RenameFile(ParamStr(0), ChangeFileExt(ParamStr(0), '.exe.bak'));
  MyIdHttp.Get('http://domain.de/domainprogramm.exe', DownloadedFile);
  DownloadedFile.SaveToFile(ParamStr(0));
  ShellExecute(application.Handle, 'open', PChar(ParamStr(0)),
    PChar('/delete "' + ChangeFileExt(ParamStr(0), '.exe.bak') + '"'), '', SW_SHOWNORMAL);
  end;


und es kommt
Zitat:
Variable DownloadFile ist möglicherweise nicht initialisiert worden;
Variable MyIdhttp ist möglicherweise nicht initialisiert worden
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Sa 06.06.09 13:19 
Also ich kenne mich nun leider in dem Bereich noch gar nicht aus, aber durch meine Suche bin ich hier darauf gestoßen, dass bei Dir wohl noch dieses fehlt:
ausblenden Delphi-Quelltext
1:
DownloadedFile := TMemoryStream.create;					

Oder? - Deute ich das jetzt gerade falsch?
kulka1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 06.06.09 13:38 
habe es eingefügt
jetzt kommt noch die meldung

ausblenden Delphi-Quelltext
1:
Variable MyIdhttp ist möglicherweise nicht initialisiert worden					
Timosch
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1314

Debian Squeeze, Win 7 Prof.
D7 Pers
BeitragVerfasst: Sa 06.06.09 14:54 
Dann mach das gleiche auch mit MyIdHttp. Und les dir ein Grundlagen-Tutorial durch.

_________________
If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell