Icon extrahieren und speichern als Bitmap!
-
Hallo!
Ich suche nach einer Möglichkeit um aus einer Exe-Datei ein Icon zu extrahieren.
Dieses soll wenn möglich als Bitmap gepseichert werden?
Vielen Dank!
-
Vielleicht hilft dir das weiter:
//--------------------------------------------------------------------------- // Extrahiert das Icon einer Exe-Datei: // // Parameter: // // AnsiString exepath: Der Pfad der zu verwendenden Exe-Datei // int size: 0 für 16*16 und 1 für 32*32 // TBitmap *bmp: Pointer auf Bitmap; (default == NULL) // TIcon *ico: Pointer auf Icon; (default == NULL) // // Rückgabewerte: // // Erfolgreich = 0 // Exe-Datei existert nicht = 1 // //--------------------------------------------------------------------------- int __fastcall TFmExtractExeIcon::ExtractExeIcon( AnsiString exepath, int size, Graphics::TBitmap *bmp, Graphics::TIcon *ico ) { if( !FileExists(exepath) ) return 1; TRect rect; bool newbmp = false; bool newico = false; if( bmp == NULL ) { bmp = new Graphics::TBitmap(); newbmp = true; } if( ico == NULL ) { ico = new Graphics::TIcon(); newico = true; } ico->Handle = ExtractIcon( 0, exepath.c_str(), 0 ); if( size == 0 ) { rect = Rect(0, 0, 16, 16); bmp->Width = 16; bmp->Height = 16; } else if( size == 1 ) { rect = Rect(0, 0, 32, 32); bmp->Width = 32; bmp->Height = 32; } else { rect = Rect(0, 0, 16, 16); bmp->Width = 16; bmp->Height = 16; } // bmp->Height = ico->Height; // bmp->Width = ico->Width; // bmp->Canvas->Draw(0, 0, ico); bmp->Canvas->StretchDraw(rect, ico); ico->Height = 16; ico->Width = 16; if( newbmp ) delete bmp; if( newico ) delete ico; return 0; } //---------------------------------------------------------------------------
Keine Ahnung, wo das herkommt, lag bei mir auf der Platte...