Форум программистов «Весельчак У»
  *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

  • Рекомендуем проверить настройки временной зоны в вашем профиле (страница "Внешний вид форума", пункт "Часовой пояс:").
  • У нас больше нет рассылок. Если вам приходят письма от наших бывших рассылок mail.ru и subscribe.ru, то знайте, что это не мы рассылаем.
   Начало  
Наши сайты
Помощь Поиск Календарь Почта Войти Регистрация  
 
Страниц: [1]   Вниз
  Печать  
Автор Тема: Достать иконку из запущеного процесса!!  (Прочитано 11450 раз)
0 Пользователей и 1 Гость смотрят эту тему.
USBLexus
Опытный

ru
Offline Offline
Пол: Мужской
Кот рыжий


« : 16-03-2005 11:03 » 

Вот такая вот проблемма, нужно вытащить иконку запущеного приложения... Никто не сталкивался?
Записан

#define QUESTION(b) (2*b)||(!(2*b)) (c) William Shakespeare
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #1 : 16-03-2005 13:04 » 

Иконка твоего приложения или чужого?
Для своего приложения:
Есть такая API функция EnumResourceNames Она позволяет просмотреть все ресурсы файла данного типа.
Цитата
The EnumResourceNames function searches a module for each resource of the specified type and passes the name of each resource it locates to an application-defined callback function.

BOOL EnumResourceNames(

    HINSTANCE hModule,   // resource-module handling
    LPCTSTR lpszType,   // pointer to resource type
    ENUMRESNAMEPROC lpEnumFunc,   // pointer to callback function
    LONG lParam    // application-defined parameter
   );   
 

Parameters

hModule

Identifies the module whose executable file contains the resources for which the names are to be enumerated. If this parameter is NULL, the function enumerates the resource names in the module used to create the current process.

lpszType

Points to a null-terminated string specifying the type name of the resource for which the name is being enumerated. For standard resource types, this parameter can be one of the following values:

Value   Meaning
RT_ACCELERATOR   Accelerator table
RT_ANICURSOR   Animated cursor
RT_ANIICON   Animated icon
RT_BITMAP   Bitmap resource
RT_CURSOR   Hardware-dependent cursor resource
RT_DIALOG   Dialog box
RT_FONT   Font resource
RT_FONTDIR   Font directory resource
RT_GROUP_CURSOR   Hardware-independent cursor resource
RT_GROUP_ICON   Hardware-independent icon resource
RT_ICON   Hardware-dependent icon resource
RT_MENU   Menu resource
RT_MESSAGETABLE   Message-table entry
RT_RCDATA   Application-defined resource (raw data)
RT_STRING   String-table entry
RT_VERSION   Version resource
 

lpEnumFunc

Points to the callback function to be called for each enumerated resource name. For more information, see the EnumResNameProc function.

lParam

Specifies an application-defined value passed to the callback function. This parameter can be used in error checking.

 

Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The EnumResourceNames function continues to enumerate resource names until the callback function returns FALSE or all resource names have been enumerated.
где,
Цитата
he EnumResNameProc function is an application-defined callback function that receives resource names as a result of a call to the EnumResourceNames function.

BOOL CALLBACK EnumResNameProc(

    HANDLE hModule,   // resource-module handle
    LPCTSTR lpszType,   // pointer to resource type
    LPTSTR lpszName,   // pointer to resource name
    LONG lParam    // application-defined parameter 
   );   
 

Parameters

hModule

Identifies the module whose executable file contains the resources for which the names are being enumerated. If this parameter is NULL, the function enumerates the resource names in the module used to create the current process.

lpszType

Points to a null-terminated string specifying the type name of the resource for which the name is being enumerated. For standard resource types, this parameter should be one of the following values:

Value   Meaning
RT_ACCELERATOR   Accelerator table
RT_ANICURSOR   Animated cursor
RT_ANIICON   Animated icon
RT_BITMAP   Bitmap resource
RT_CURSOR   Hardware-dependent cursor resource
RT_DIALOG   Dialog box
RT_FONT   Font resource
RT_FONTDIR   Font directory resource
RT_GROUP_CURSOR   Hardware-independent cursor resource
RT_GROUP_ICON   Hardware-independent icon resource
RT_ICON   Hardware-dependent icon resource
RT_MENU   Menu resource
RT_MESSAGETABLE   Message-table entry
RT_RCDATA   Application-defined resource (raw data)
RT_STRING   String-table entry
RT_VERSION   Version resource
 

lpszName

Points to a null-terminated string specifying the name of the resource for which the name is being enumerated.

lParam

Specifies the application-defined parameter passed to the EnumResourceNames function. This parameter can be used in error checking.

 

Return Values

This callback function should return TRUE to continue enumeration; otherwise, it should return FALSE to stop enumeration.

Remarks

The EnumResNameProc function is a placeholder for the application-defined or library-defined function name.
Чтобы считать иконку, есть функция
Цитата
he LoadIcon function loads the specified icon resource from the executable (.EXE) file associated with an application instance.

HICON LoadIcon(

    HINSTANCE hInstance,   // handle of application instance
    LPCTSTR lpIconName    // icon-name string or icon resource identifier
   );   
 

Parameters

hInstance

Identifies an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a standard icon is being loaded.

lpIconName

Points to a null-terminated string that contains the name of the icon resource to be loaded. Alternatively, this parameter can contain the resource identifier in the low-order word and zero in the high-order word. Use the MAKEINTRESOURCE macro to create this value.

To use one of the Windows predefined icons, set the hInstance parameter to NULL and the lpIconName parameter to one of the following values:

Value   Description
IDI_APPLICATION   Default application icon.
IDI_ASTERISK   Asterisk (used in informative messages).
IDI_EXCLAMATION   Exclamation point (used in warning messages).
IDI_HAND   Hand-shaped icon (used in serious warning messages).
IDI_QUESTION   Question mark (used in prompting messages).
IDI_WINLOGO   Windows logo.
 

Return Values

If the function succeeds, the return value is the handle of the newly loaded icon.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

LoadIcon loads the icon resource only if it has not been loaded; otherwise, it retrieves a handle to the existing resource. The function searches the icon resource for the icon most appropriate for the current display. The icon resource can be a color or monochrome bitmap.
LoadIcon can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values. Use the LoadImage function to load icons of other sizes.

Для чужого приложения:
Прочитай книгу Рихтера "Windows - для проффессионалов", в частности Главу 4. Там дается исходный код программы, которая дает информацию по запушенным процессам. Там в частности есть возможность узнать имя файла каждого модуля запушенного процесса. Затем просто, считываеш данный модуль в память как библиотеку без запуска, и дальше действуеш, как описано выше.
Записан

Не будите спашяго дракона.
             Джаффар (Коша)
USBLexus
Опытный

ru
Offline Offline
Пол: Мужской
Кот рыжий


« Ответ #2 : 17-03-2005 03:07 » 

Мне нужно для чужого приложения

>Прочитай книгу Рихтера "Windows - для проффессионалов", в частности Главу 4. Там дается исходный код программы, которая дает >информацию по запушенным процессам. Там в частности есть возможность узнать имя файла каждого модуля запушенного процесса. Затем >просто, считываеш данный модуль в память как библиотеку без запуска, и дальше действуеш, как описано выше.

Должен быть обязательно способ попроще без загрузки модуля да и потом как я узню какая иконка приложения? В модуле их может быть несколько...
Записан

#define QUESTION(b) (2*b)||(!(2*b)) (c) William Shakespeare
Finch
Спокойный
Администратор

il
Offline Offline
Пол: Мужской
Пролетал мимо


« Ответ #3 : 17-03-2005 12:43 » 

Тут описывается определение иконок при помоши Shell функций. http://www.rsdn.ru/article/winshell/shlext9.xml
Записан

Не будите спашяго дракона.
             Джаффар (Коша)
USBLexus
Опытный

ru
Offline Offline
Пол: Мужской
Кот рыжий


« Ответ #4 : 18-03-2005 03:12 » 

Тут описывается определение иконок при помоши Shell функций. http://www.rsdn.ru/article/winshell/shlext9.xml
Ok! спасибо, попозже попробую разобраться потом напишу что получилось
Записан

#define QUESTION(b) (2*b)||(!(2*b)) (c) William Shakespeare
Алексей++
глобальный и пушистый
Глобальный модератор

ru
Offline Offline
Сообщений: 13


« Ответ #5 : 15-07-2008 05:22 » 

ситуация у мну такая: в ресурсы вставлени файл, загружаю ресурс в программе:
Код:
	HRSRC hrsrc=0;
if(hrsrc=::FindResource(0,MAKEINTRESOURCE(IDR_res1),"BIN"))
{
HGLOBAL hgl=0;
if(hgl=::LoadResource(0,hrsrc))
{
void* pData=0;
if(pData=::LockResource(hgl))
{
//pData


::FreeResource(hgl);
}
}
}


как узнать размер данных то , на которые теперь указывает pData ? Улыбаюсь
Или размер надо прописывать вручную ? Несерьёзно...
Записан

zubr
Гость
« Ответ #6 : 15-07-2008 09:15 » 

SizeofResource
Записан
Алексей++
глобальный и пушистый
Глобальный модератор

ru
Offline Offline
Сообщений: 13


« Ответ #7 : 15-07-2008 09:30 » 

точно, спасибо )
Блин, а почему в мсдн нигде не упомянуто там, где идёт описание остальных функций ?  Странно , забыли что ли )
Записан

Страниц: [1]   Вверх
  Печать  
 

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines