Autor Beitrag
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Fr 04.07.03 08:41 
Hi @ll,

mich würd mal interessieren ob es möglich gibt das Symbol einer Exe nachträglich zu ändern. Ich hab mal das application.icon per imagelist.geticon() zufällig gesetzt, dies ändert jedoch nur das Symbol in der Titelleiste, geht das auch mit der Exe ?
(sowas wie in Delphi Projekt\Optionen\Anwendung\Symbol laden)

_________________
mfg
Tana´Ri
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Fr 04.07.03 10:27 
Hab dir da mal was online gestellt:

assarbad.net/stuff/!export/2.rar

Es ist ein kleines Progrämmle (Console) von "Casio" (siehe SL) und mir.
Tana´Ri Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Fr 04.07.03 11:13 
thx

ich hatte es erst so versucht, doch das funktioniert nicht.
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:
procedure TForm1.Button1Click(Sender: TObject);
var icon : TIcon;
    hExeFile : cardinal;
    IcoToInsert  : cardinal;
    rec : tsearchrec;
begin
   Icon := TIcon.Create;
   { we need the filesize ( TSearchRec.Size ) }
   if FindFirst (
       pchar (extractfilepath (application.ExeName)+'Res\console.ico'),
       faAnyFile,
       rec
     ) = 0 
   then
   try
    { get Icon }
    Icon.LoadFromFile (extractfilepath (application.ExeName)+'Res\console.ico');
    { get handle of exe to update }
    hExeFile := BeginUpdateResource(pchar(application.ExeName),false);
    if hExeFile <> 0 then
     try        
       // UpdateResource (
       //     hExeFile, RT_STRING, 
       //     pResourceID, LANG_NEUTRAL, 
       //     PWideChar(sBuffer), iDataSize);
      UpdateResource(hExeFile,
                     RT_ICON,
                     pchar(application.ExeName),
                     LANG_NEUTRAL{MAKELANGID(LANG_GERMAN,SUBLANG_GERMAN)},
                     @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.
ausblenden 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 :roll:

zum iconfile noch ne frage, muss das *.ico sein ?

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.

_________________
mfg
Tana´Ri
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Fr 04.07.03 19:26 
ResID ist die Ressourcen-ID der Ressource. Ist immer die niedrigste, welche als Default-Icon verwendet wird. Wie e zwischen IDs mit Text und jenen numerischen zwischen 0-$FFFF-1 aussieht, habe ich noch nicht getestet.

Auf keinen Fall ist es nochmal der EXE-Name *oder sagen wir mal so, das waere sehr ungweoehnlich).
Tana´Ri Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Di 08.07.03 13:35 
Hi Assarbard,

das funktioniert bei mir nicht; ich rufe deine Funktion folgendermaßen auf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
(*
ICONFILE = Pfad der Icodatei
ID = im Breich (0 .. $FFFF-1) meist beließ ich es bei zero
*)


UpdateApplicationIcon(pchar(ICONFILE),pchar(ParamStr(0)),MAKEINTRESOURCE(ID),LANG_NEUTRAL)

Die Funktion liefert TRUE zurück und trotzdem erscheint bei der Exedatei bzw. in der Titelleiste das neue Icon nicht. Wobei es mir ja um das Symbol der Exe geht, das Titeleistensymbol lässt sich leicht über application.icon setzen. die Exedateien greifen doch auf ein Icofile oder meist auf ne DLL zurück.

_________________
mfg
Tana´Ri
scrooge
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 200



BeitragVerfasst: Mi 09.07.03 20:37 
Hab mir mal das Programm runtergeladen und irgendwie bin ich zu blöd die DAtei so zu öffnen, dass ich das Programm auch sehen kann. (*.rar nie gehört)
Tana´Ri Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Do 10.07.03 08:13 
WinRaR

Es funktioniert !!

thx a lot @Assarbard 8)

_________________
mfg
Tana´Ri
scrooge
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 200



BeitragVerfasst: Do 10.07.03 13:50 
Hi,

hab noch ne Frage zum Resource manipulieren. Hab das ganze mal mit Strings probiert, nur kommt da nur Mist am Ende raus. Wäre daher nettwenn mir einer en funzenden Code dafür geben könnte. (Strings müssen doch zuerst in Widechar konvert. werden, oder ??)

Hab bis jetzt den benutzt:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.SpeedButton2Click(Sender: TObject);
var Handle :THandle;
s :string;
s2 :WideChar;
strPointer :Pointer;
begin
s := 'dfdgght';
strPointer := @s;
s2 := WideChar(strPointer^);

Handle := BeginUpdateResource('Server.exe', false);
UpdateResource(Handle, RT_STRING,MAKEINTRESOURCE(1),1031, @s2,sizeof(WideChar));

EndUpdateResource(Handle, false);
end;