Autor Beitrag
JayK
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: So 04.09.05 13:25 
Hallo, ich habe eine Frage (und ein Problem) zu (mit) Popovs FAQ-Beirag "Icons aus EXE, DLL oder ICO extrahieren".

Popov hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
uses
  ShellApi;

// Gibt Anzahl Icons aus EXE, DLL oder ICO.
function TotalNumberOfIcons(const FileName: String): Integer;
begin
  if not FileExists(FileName) then Result := -1
    else Result := ExtractIcon(HInstance, PChar(FileName), -1);
end{Popov}

An der hervorgehobenen Stelle wird in D2k5 aber ein System.Cardinal erwartet. Also geht -1 nicht. Was mache ich jetzt damit?
Mit 0 funzt es nicht, da kommt für eine ICO-Datei immer wieder was anderes im Hunderttausenderbereich raus, obwohl nur ein Icon drin ist :lol:
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 04.09.05 13:30 
-1 ist der iconindex der die anzahl der vorhandenen icons zurückgibt, ich kenne keine andere möglichkeit das zu ermitteln, gibt bestimmt eine, nur ist die bestimmt komplizierter 8)

0 wäre das erste icon, also an der -1 kanns eigenltich nicht liegen, hm dürfen cardinals negativ sein ?


Zuletzt bearbeitet von F34r0fTh3D4rk am So 04.09.05 13:31, insgesamt 1-mal bearbeitet
JayK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: So 04.09.05 13:31 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
hm dürfen cardinals negativ sein ?

eben nicht :roll: das ist ja mein Problem. Die funktion der -1, wenn ich die benutzen könnte, hab ich nicht angezweifelt.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 04.09.05 13:32 
das ist doch bestimmt ne api funktion, dann würde ich sagen manuell implementieren 8)
JayK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: So 04.09.05 13:34 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
das ist doch bestimmt ne api funktion, dann würde ich sagen manuell implementieren 8)

Und wie? Ich weiß nicht, wie man das macht. Wie soll ich eine API-Funktion neu machen, wenn ich die Quellcodes des Originals nichtmal einsehen kann?
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 04.09.05 13:38 
aus ner dll importieren 8)

Suche im MSDN EXTRACTICON

bei mir hats funktioniert: seth2000.se.funpic.d...p;um=show&fid=11
JayK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: So 04.09.05 13:45 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
aus ner dll importieren 8)

Und nochmal die Frage :rofl: : Wie geht das?

Die von mS sind ja auch lustig :roll:
Der letzte Parameter ist ein UINT (entspricht Cardinal, also natürliche Zahlen) und dann weiter "wenn das -1 ist, dann kommt sowas raus" :motz: Sind die doof?! Oder hab ich ein Brett vorm Kopf?
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 04.09.05 13:47 
vielleicht geht cardinal von -1 bis maxuintalue ? :lol:
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 04.09.05 13:49 
Im MSDN ist als Typ ebenfalls UINT angegeben, Cardinal hat also formal seine Richtigkeit. Als Index für die Anzahl der Icons wird à angegeben. Du kannst es also entweder mit $FFFFFFFF, 4294967295, Cardinal(-1) oder mit Cardinal(not 0) machen, alle vier Möglichkeiten funktionieren (zumindest mit Delphi7).

Edit: @JayK: Nein, MS sagt nicht, daß man -1 angeben soll!

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
JayK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: So 04.09.05 13:52 
Aha.
Und ich dachte schon, dass mit dem à sei ein Druckfehler :lol:
kann es jetzt aber nicht ausprobieren, weil ich los muss.
Schankedön. Bis nachher oder morgen! ;)

Edit:
user profile icontommie-lie hat folgendes geschrieben:
Nein, MS sagt nicht, daß man -1 angeben soll!

Popov aber schon... (in den FAQ)
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 04.09.05 14:02 
bei mir hat's glaube ich mit -1 gefunzt, kA 8)

ah nee, ich hab cardinal(-1) genommen ;) liegt ja auch nahe bei der meldung ;)

Zitat:

Mit 0 funzt es nicht, da kommt für eine ICO-Datei immer wieder was anderes im Hunderttausenderbereich raus, obwohl nur ein Icon drin ist

damit erhälst du ja auch das icon ;)
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 04.09.05 14:05 
user profile iconJayK hat folgendes geschrieben:
user profile icontommie-lie hat folgendes geschrieben:
Nein, MS sagt nicht, daß man -1 angeben soll!
Popov aber schon... (in den FAQ)
Du hast oben aber die Schuld "denen von MS" in die Schuhe geschoben. Die können auch nichts dafür, wenn alte Delphi-Versionen (laut Profil verwendet Popov Delphi3) die Funktionen falsch importieren oder Popov die MS-Doku nicht richtig liest, "die von MS" sind also unschuldig.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 04.09.05 14:09 
letztenendes ist das nur eine typumwandlung also garnet mal soooo wild ;)
JayK Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1013



BeitragVerfasst: Fr 09.09.05 14:44 
user profile icontommie-lie hat folgendes geschrieben:
Du hast oben aber die Schuld "denen von MS" in die Schuhe geschoben.

Ja sorry. :roll: Ich hab mich im Bezug auf

user profile icontommie-lie hat folgendes geschrieben:
Nein, MS sagt nicht, daß man -1 angeben soll!

eben verlesen... kann doch mal passieren, oder? Und ich hatte mich eben so verlesen, dass man -1 hinschreiben soll. Also hab ich an den geistigen Fähigkeiten MS-Leuten, die den Bericht geschrieben haben, (fälschlicherweise, wie sich jetzt rausstellte) gezweifelt. :lol:

user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
ah nee, ich hab cardinal(-1) genommen ;)

wäre nett, wenn du dich darum kümmerst, dass das korrigiert wird (in den FAQ) ;)
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 09.09.05 15:37 
Zitat:

user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
ah nee, ich hab cardinal(-1) genommen ;)

wäre nett, wenn du dich darum kümmerst, dass das korrigiert wird (in den FAQ) ;)


hä ? wieso denn ich ? dafür gibt's doch die mods :lol: