1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| HICON getHiconForDoc(String ext,int fen)
{
HANDLE hCurrentInst;
HICON hicon;
AnsiString Pathicon="";
int index;
TRegistry *Reg = new TRegistry();
Reg->RootKey = HKEY_CLASSES_ROOT;
if(Reg->OpenKey(ext, false))
{
String nom = Reg->ReadString("") + "\\DefaultIcon";
Reg->CloseKey();
Reg->RootKey = HKEY_CLASSES_ROOT;
if(Reg->OpenKey(nom,false))
{
Pathicon = Reg->ReadString("");
}
}
delete Reg;
if(Pathicon.Pos(",") != 0)
{
index = Pathicon.SubString(Pathicon.Pos(",")+1,Pathicon.Length()).ToInt();
Pathicon = Pathicon.SubString(0,Pathicon.Pos(",")-1);
}
hCurrentInst = (HINSTANCE) GetWindowLong((HANDLE)fen, GWL_HINSTANCE);
hicon = ExtractIcon(hCurrentInst, Pathicon.c_str(), index);
return hicon;
} |