Легенда:
новое сообщение
закрытая нитка
новое сообщение
в закрытой нитке
старое сообщение
|
- Напоминаю, что масса вопросов по функционированию форума снимается после прочтения его описания.
- Новичкам также крайне полезно ознакомиться с данным документом.
Вот что получилось 28.10.02 02:05 Число просмотров: 1364
Автор: Disappear Статус: Незарегистрированный пользователь
|
HICON LoadIconFromExt(LPCTSTR szExt, bool LargeIcon)
{
CRegKey key;
TCHAR szTemp[MAX_PATH];
szTemp[0] = 0;
CString sExt(szExt);
int pos = sExt.ReverseFind('.');
if (pos > 0)
sExt = sExt.Right(sExt.GetLength() - pos);
sExt.MakeLower();
HICON hIcon = NULL;
CString sLocation;
UINT index = 0;
if (key.Open(HKEY_CLASSES_ROOT, sExt) == ERROR_SUCCESS)
{
TCHAR szValue[100];
szValue[0] = 0;
DWORD count = 100;
key.QueryValue(szValue, NULL, &count);
key.Close();
if (szValue[0])
{
CString sKey(szValue);
sKey += "\\DefaultIcon";
if (key.Open(HKEY_CLASSES_ROOT, sKey) == ERROR_SUCCESS)
{
count = MAX_PATH;
key.QueryValue(szTemp,NULL, &count);
CString str(szTemp);
int pos = str.ReverseFind(',');
if (pos == -1) pos = str.ReverseFind('%');
if (pos > 0)
index = atoi(str.Right(str.GetLength() - pos - 1));
str = str.Left(pos);
sLocation = str;
key.Close();
}
if (sLocation.GetLength() < 2)
{
sKey = szValue;
sKey += "\\shell\\open\\command";
if (key.Open(HKEY_CLASSES_ROOT, sKey) == ERROR_SUCCESS)
{
count = MAX_PATH;
key.QueryValue(szTemp,NULL, &count);
sLocation = szTemp;
int pos = sLocation.ReverseFind('\"');
if (pos > 0)
sLocation = sLocation.Left(pos);
sLocation.Replace("\"","");
key.Close();
}
}
}
}
if (!sLocation.IsEmpty())
{
if (LargeIcon)
ExtractIconEx(sLocation, index, &hIcon, NULL, 1);
else
ExtractIconEx(sLocation, index, NULL, &hIcon, 1);
}
if (!hIcon)
{
CString str = "%SystemRoot%\\system32\\shell32.dll";
int index;
if (sExt == ".exe")
index = 2;
else
index = 0;
if (LargeIcon)
ExtractIconEx(str, index, &hIcon, NULL, 1);
else
ExtractIconEx(str, index, NULL, &hIcon, 1);
}
return hIcon;
}
|
|
|