Autor Beitrag
Schamese
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Windows 2008 Server
Delphi 5 Ent., C# (Visual Studio 2008)
BeitragVerfasst: Mo 06.11.06 18:39 
Hi.

Ich haben folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
 function LoadIconFromRessourceName(RessourceName: string): TIcon; 
 begin 
      Result := TIcon.Create; 
      Extract(RessourceName, '\qwertz.ico'); 
      Result.LoadFromFile('\qwertz.ico'); 
      DeleteFile('\qwertz.ico'); 
 end;


die Methode Extract:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
 function Extract(Resourcename, FileName: string): Boolean; 
 var MyRessource: TResourceStream; 
 begin 
      Result := True; 
      try 
         MyRessource := TResourceStream.Create(hInstance, Resourcename, 'RT_RCDATA'); 
         try 
            MyRessource.SaveToFile(Filename); 
         finally 
                MyRessource.Free; 
         end
      except 
            on E: Exception do 
               begin 
                    Result := False; 
                    ShowMessage(E.Message); 
               end
      end
 end;


In der Methode LoadIconFromRessourceName kommt bei Result.LoadFromFile('..'); der Fehler 'Ungültiges Symbol' vom Typ EInvalidGraphic.

Was mache Ich Falsch?

PS: Selbe Frage bei www.entwickler-forum.de


Moderiert von user profile iconChristian S.: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mo 06.11.2006 um 18:41
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 06.11.06 18:54 
Haste mal geguckt, ob eine Datei erzeugt wurde, und ob da ein gültiges Icon drin is?

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Schamese Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Windows 2008 Server
Delphi 5 Ent., C# (Visual Studio 2008)
BeitragVerfasst: Mo 06.11.06 19:02 
Ich hab die Datei per Editor in die Exe Geladen, die extrahierte Symboldatei ist also Gültig.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 06.11.06 19:24 
Nur weil die Datei in der Exe höchstwahrscheinlich gültig ist, muss die extrahierte Datei nicht auch glütig sein. :roll:
Hast du die mit dem Programm extrahierte Datei geprüft, ja oder nein?

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Schamese Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Windows 2008 Server
Delphi 5 Ent., C# (Visual Studio 2008)
BeitragVerfasst: Di 07.11.06 18:32 
ja, Hab ich.

Zitat:
Ich hab die Datei per Editor in die Exe Geladen, die extrahierte Symboldatei ist also Gültig.


Damit meinte ich, dass ich die Datei nach dem Extrahieren nochmal zum Test in Die Exe geladen habe.
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: Di 07.11.06 20:15 
Dir ist schon bewusst, dass das '\' vor 'qwertz.ico' auf den Laufwerksroot zugreift und nicht auf dein aktuelles Verzeichnis? Solche Sachen sollten normalerweise in ein Temp-Verzeichnis, da ist auch sichergestellt, dass man Schreibrechte hat etc.
Die Datei extrahiert er korrekt (eben wegen Schreibrechten etc.)?

user profile iconSchamese hat folgendes geschrieben:
Damit meinte ich, dass ich die Datei nach dem Extrahieren nochmal zum Test in Die Exe geladen habe.

Wie? Normalerweise sollte das einmal zur Compiletime vom Delphi-Compiler (oder Linker?) erledigt werden und das musst du normalerweise nicht per Hand machen!

MrSaint

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems
Schamese Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Windows 2008 Server
Delphi 5 Ent., C# (Visual Studio 2008)
BeitragVerfasst: Mi 08.11.06 17:17 
den Pfad habe ich nur als BSP eingesetzt und ich will je nach dem mit welchem parameter dass programm gestartet wurde, das icon der form Ändern:
Parameter: -blue - Blaues Icon
-red - Rotes Icon
etc.
Schamese Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Windows 2008 Server
Delphi 5 Ent., C# (Visual Studio 2008)
BeitragVerfasst: Di 12.12.06 20:38 
Hat sich inzwischen erledigt.