Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C#: Icons aus Datei lesen

Empfohlene Antworten

Veröffentlicht

Hallo!

Hab mal wieder ne Frage *g*

Wie kann ich mit Hilfe von C# aus einer Datei (.exe,.pdf) das zugeordnete Icon ermitteln?

Danke und Gruß

Azrael

Indem du die API-Funktion ExtractIcon oder ExtractIconEx aus der shell32 wrappst.

Servus!

Ja hab ich gemacht allerdings krieg ich da immer einen Fehler:

"Ungültiger Parameter verwendet!"

hier mal ein auszug aus meinem Code:

Wrappen der API Funktion:


[System.Runtime.InteropServices.DllImportAttribute("SHELL32.dll")]

public static extern System.IntPtr ExtractIcon(int hInstance, String FileName, int iconIndex);

Ermitteln des Icons aus der Datei:

System.IntPtr hIcon;

System.Drawing.Bitmap bitmap;


hIcon = ExtractIcon(0,File,0);

bitmap = System.Drawing.Bitmap.FromHicon(hIcon);

Gruß

Azrael

Also die Fehlermeldung hab ich jetzt beseitigt indem ich prüfe ob der Ptr 0 ist oder nicht...

Soweit klappt es auch, dass ich aus .exe,.dll usw die icons bekomme!

Allerdings weiß ich nicht wie ich die Icons bekomme bei Dateien denen ein Icon zugeordnet ist, d.h. die in der Datei selber kein Icon haben

Weiß jemand wie das geht?

Nimm ExtractAssociatedIcon aus der gleichen .dll.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.