thx
ich hatte es erst so versucht, doch das funktioniert nicht.
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:
| procedure TForm1.Button1Click(Sender: TObject); var icon : TIcon; hExeFile : cardinal; IcoToInsert : cardinal; rec : tsearchrec; begin Icon := TIcon.Create; if FindFirst ( pchar (extractfilepath (application.ExeName)+'Res\console.ico'), faAnyFile, rec ) = 0 then try Icon.LoadFromFile (extractfilepath (application.ExeName)+'Res\console.ico'); hExeFile := BeginUpdateResource(pchar(application.ExeName),false); if hExeFile <> 0 then try UpdateResource(hExeFile, RT_ICON, pchar(application.ExeName), LANG_NEUTRAL, @Icon, rec.size); finally EndUpdateResource(hExeFile, false); end; finally findClose(rec); Icon.Free; end; end; |
is ja schon richtige Richtung gewesen, doch zu deiner funktion hab mal noch fragen, ich hab mal die UpdateApplicationIcon zum testen in eine neue anwendung eingebaut wo ich sie so aufrufe:
da deine anwendung bzw. console sich bei mir direkt nach dem dclick schließt wollte ich den kern mal auslagern.
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| procedure TForm1.Button1Click(Sender: TObject); var ICONFILE : string; begin if opdlg.execute then begin ICONFILE := opdlg.FileName; if UpdateApplicationIcon ( pchar (ICONFILE), pchar (application.ExeName), pchar (application.ExeName), LANG_NEUTRAL ) = FALSE then ShowMessage('Das Exe Symbol konnte nicht aktualisiert werden.'); end; end; |
der Parameter ResID ist ja für der 3 Param der UpdateResource () also
lauft help
LPCTSTR lpName, // address of resource name to update
funktioniert bei mir aber net, ich geh ma davon aus das ich grad auf dem schlauch steh und es net raff, what´s wrong
zum iconfile noch ne frage, muss das *.ico sein ?
Moderiert von
Tino: Code- durch Delphi-Tags ersetzt.