#contents
*ÆÃÄê¤Î¥Õ¥¡¥¤¥ë¤«¤é¥¢¥¤¥³¥ó¤ò¼è¤ê½Ð¤·¤Æ¡¢¥¤¥á¡¼¥¸¥ê¥¹¥È¤Ë³ÊǼ [#k7c482e3]
**»ÈÍѤ¹¤ë¥³¥ó¥Ý¡¼¥Í¥ó¥È [#mb117d33]
-TButton *Button1;
-TImageList *imglst_Tree;
-TImage *Image1;
**¥½¡¼¥¹¥³¡¼¥É [#ebf96dfa]
void __fastcall Tform_Main::Button1Click(TObject *Sender)
{
//ÆÃÄê¤Î¥Õ¥¡¥¤¥ë¤Ë´ØÏ¢¤Å¤±¤é¤ì¤¿¥¢¥¤¥³¥ó¤ò¼è¤ê½Ð¤¹
SHFILEINFO shfi;
HICON hSmallIcon;
TIcon *icoData;
icoData = new TIcon;
char WindowsPath[255], SystemPath[255];
GetWindowsDirectory(WindowsPath, sizeof(WindowsPath)); //¥¦¥£¥ó¥É¥¦¥º¥Õ¥©¥ë¥À¤Î¥Ñ¥¹¤ò¼èÆÀ
//strcat(WindowsPath, "\\explorer.exe");
GetSystemDirectory(SystemPath, sizeof(SystemPath)); //¥·¥¹¥Æ¥à¥Õ¥©¥ë¥À¤Î¥Ñ¥¹¤ò¼èÆÀ
//strcat(SystemPath, "\\shell32.dll");
//¥¹¥â¡¼¥ë¥¢¥¤¥³¥ó¤Î¼èÆÀ
if(SHGetFileInfo(WindowsPath, FILE_ATTRIBUTE_ARCHIVE,
&shfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON ) != 0 ){
icoData->Handle = shfi.hIcon;
}
//¼èÆÀ¤·¤¿¥¢¥¤¥³¥ó¤ò¥¤¥á¡¼¥¸¥ê¥¹¥È¤ØÄɲÃ
imglst_Tree->AddIcon(icoData);
//¥¤¥á¡¼¥¸¥ê¥¹¥È¤Î0ÈÖÌܤÎÃæ¿È¤òɽ¼¨
imglst_Tree->GetIcon(0, Image1->Picture->Icon);
delete icoData;
}
**²òÀâ [#nd92a307]
15¹ÔÌÜÉÕ¶á¤Î"SHGetFileInfo"´Ø¿ô¤Î°ú¿ô¤ò"SHGFI_SMALLICON"¤«¤é"SHGFI_LARGEICON"¤ËÊѤ¨¤ì¤Ð¡¢Â礤¤¥¢¥¤¥³¥ó¤¬¼è¤ê½Ð¤»¤Þ¤¹¡£
----
*ÆÃÄê¤Î¥Õ¥¡¥¤¥ë¤Ë´ØÏ¢¤Å¤±¤é¤ì¤Æ¤¤¤ë¥¢¥¤¥³¥ó¤ò¡¢¥¤¥á¡¼¥¸¥ê¥¹¥È¤Ë³ÊǼ [#ydef50be]
**»ÈÍѤ¹¤ë¥³¥ó¥Ý¡¼¥Í¥ó¥È [#r8223d5d]
-TButton *Button1;
-TImageList *imglst_Tree;
-TImage *Image1;
**¥½¡¼¥¹¥³¡¼¥É [#g0daa4c9]
void __fastcall Tform_Main::Button1Click(TObject *Sender)
{
//ÆÃÄê¤Î¥Õ¥¡¥¤¥ë¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¥¢¥¤¥³¥ó¤ò¤È¤ê¤À¤¹
int nIndex = 0; // ¼èÆÀ¤·¤¿¤¤¥¢¥¤¥³¥ó¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹
HICON hLicon; // Â礤¤¥¢¥¤¥³¥ó
HICON hSicon; // ¾®¤µ¤¤¥¢¥¤¥³¥ó
ExtractIconEx( Application->ExeName.c_str(), nIndex, &hLicon, &hSicon, 1 );
// ¥¢¥¤¥³¥óºîÀ®
TIcon *Ico = new TIcon();
Ico->Handle = hSicon;
// ²¿¤é¤«¤Î½èÍý¤òµ½Ò
imglst_Tree->AddIcon( Ico );
//¥¤¥á¡¼¥¸¥ê¥¹¥È¤ÎÃæ¿È¤òɽ¼¨
imglst_Tree->GetIcon(0, Image1->Picture->Icon);
// ÇË´þ
delete Ico;
}
**²òÀâ [#t600c1ca]
¼«Ê¬¼«¿È¤Î¼Â¹Ô¥Õ¥¡¥¤¥ë¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¥¢¥¤¥³¥ó¤ò¼è¤ê½Ð¤¹Îã¤Ç¤¹¡£
8¹ÔÌÜÉÕ¶á¤Î"Application->ExeName.c_str()"¤Î½ê¤òÊѤ¨¤ì¤Ð¡¢ Ǥ°Õ¤Î¥Õ¥¡¥¤¥ë¤«¤é¥¢¥¤¥³¥ó¤ò¼è¤ê½Ð¤»¤Þ¤¹¡£
3¹ÔÌÜÉÕ¶á¤Î"nIndex"¤Ç¡¢¥¢¥¤¥³¥ó¤ÎÈÖ¹æ¤ò»ØÄꤷ¤Þ¤¹¡£
[[¥×¥í¥°¥é¥ß¥ó¥°]]