BCB获取应用程序图标并显示

void __fastcall TForm1::FormCreate(TObject *Sender)
{
        SHFILEINFO FileInfo;
        int Flags;

        memset(&FileInfo, 0, sizeof(FileInfo));
        Flags = SHGFI_SYSICONINDEX | SHGFI_ICON| SHGFI_LARGEICON;

        ::SHGetFileInfo("d://CnWizards_0.9.0.470.exe", 0, &FileInfo,
                 sizeof(FileInfo), Flags);

        TIcon *pIcon = new TIcon();

//      pIcon->LoadFromFile("c://1.ico");  加载图标显示
        pIcon->Handle = FileInfo.hIcon;
        Image1->Picture->Icon->Assign(pIcon);

//        Image1->Canvas->Draw(0, 0 , pIcon);   绘制图标显示

}

你可能感兴趣的:(应用程序)