static HICON ExtractIconFromPath(const char *path) { char *comma; char file[MAX_PATH],fileFull[MAX_PATH]; int n; HICON hIcon; { // char buf[512]; // sprintf(buf,"LoadIcon %s\r\n",path); // OutputDebugStringA(buf); } lstrcpynA(file,path,SIZEOF(file)); comma=strrchr(file,','); if(comma==NULL) n=0; else {n=atoi(comma+1); *comma=0;} CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)file, (LPARAM)fileFull); #ifdef _DEBUG { // char buf[512]; // sprintf(buf,"LoadIconFull %d %s\r\n",n,fileFull); // OutputDebugStringA(buf); } #endif hIcon=NULL; ExtractIconExA(fileFull,n,NULL,&hIcon,1); return hIcon; }
/************************************************************************* * ExtractIconEx (SHELL.40) */ UINT16 WINAPI ExtractIconEx16( LPCSTR lpszFile, INT16 nIconIndex, HICON16 *phiconLarge, HICON16 *phiconSmall, UINT16 nIcons ) { HICON *ilarge,*ismall; int i, ret; if (phiconLarge) ilarge = HeapAlloc(GetProcessHeap(),0,nIcons*sizeof(HICON)); else ilarge = NULL; if (phiconSmall) ismall = HeapAlloc(GetProcessHeap(),0,nIcons*sizeof(HICON)); else ismall = NULL; ret = ExtractIconExA(lpszFile,nIconIndex,ilarge,ismall,nIcons); if (ilarge) { for (i=0;i<ret;i++) phiconLarge[i] = convert_icon_to_16(0, ilarge[i]); HeapFree(GetProcessHeap(),0,ilarge); } if (ismall) { for (i=0;i<ret;i++) phiconSmall[i] = convert_icon_to_16(0, ismall[i]); HeapFree(GetProcessHeap(),0,ismall); } return ret; }
/************************************************************************* * ExtractIconExW [SHELL32.@] */ HICON WINAPI ExtractIconExW ( LPCWSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons ) { LPSTR sFile; DWORD ret; TRACE("file=%s idx=%i %p %p num=%i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons ); sFile = FILE_strdupWtoA (GetProcessHeap(),0,lpszFile); ret = ExtractIconExA ( sFile, nIconIndex, phiconLarge, phiconSmall, nIcons); HeapFree(GetProcessHeap(),0,sFile); return ret; }
HICON GetParentProcessIcon() { HICON icon = 0; DWORD parentid = GetParentProcessId(); if( parentid != (DWORD)((ULONG_PTR)-1) ) { HANDLE parent = OpenProcess( PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, parentid ); if( parent ) { char parentname[ MAX_PATH ]; GetModuleFileNameExA( parent, 0, parentname, sizeof(parentname) ); ExtractIconExA( parentname, 0, 0, &icon, 1 ); CloseHandle( parent ); } } return icon; }
static HICON ExtractIconFromPath(const char *path, BOOL * needFree) { char *comma; char file[MAX_PATH],fileFull[MAX_PATH]; int n; HICON hIcon; lstrcpynA(file,path,sizeof(file)); comma=strrchr(file,','); if (comma == NULL) n=0; else {n=atoi(comma+1); *comma=0;} PathToAbsolute(file, fileFull); hIcon=NULL; ExtractIconExA(fileFull,n,NULL,&hIcon,1); if (needFree) *needFree=(hIcon != NULL); return hIcon; }
int GetConnectingIconForProtoCount(char *szProto) { char file[MAX_PATH],fileFull[MAX_PATH],szFullPath[MAX_PATH]; char szPath[MAX_PATH]; char *str; int ret; GetModuleFileNameA(GetModuleHandle(NULL), szPath, MAX_PATH); str=strrchr(szPath,'\\'); if(str!=NULL) *str=0; _snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\proto_conn_%s.dll", szPath, szProto); lstrcpynA(file,szFullPath,SIZEOF(file)); CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)file, (LPARAM)fileFull); ret=ExtractIconExA(fileFull,-1,NULL,NULL,1); if (ret==0&&!strcmp(szProto,"ICQ")) ret=8; return ret; }
static HICON ExtractIconFromPath(const char *path, BOOL * needFree) { char *comma; char file[MAX_PATH],fileFull[MAX_PATH]; int n; HICON hIcon; lstrcpynA(file,path,sizeof(file)); comma=strrchr(file,','); if(comma==NULL) n=0; else {n=atoi(comma+1); *comma=0;} CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)file, (LPARAM)fileFull); hIcon=NULL; ExtractIconExA(fileFull,n,NULL,&hIcon,1); if (needFree) *needFree=(hIcon!=NULL); return hIcon; }
/************************************************************************* * ExtractIconEx [SHELL32.@] */ HICON WINAPI ExtractIconExAW ( LPCVOID lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons ) { if (SHELL_OsIsUnicode()) return ExtractIconExW ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons); return ExtractIconExA ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons); }