You've made me curious. I tried and found some things out...
You can do this (I think) if you're running windows NT 3.1 or later. Not 9X. And because I have 98 I can't try it. But you can use UpdateResource, BeginUpdateResource and EndUpdateResource for NT. This is my quick code (haven't been able to try it, for I haven't got NT...):
Code:
BOOL CALLBACK enumProc(HMODULE hModule, // resource-module handle
LPCTSTR lpszType, // address of resource type
LPTSTR lpszName, // address of resource name
LONG lParam // application-defined parameter
)
{
if ((long)lpszName < *(long *)lParam)
*(long *)lParam = (long)lpszName;
return true;
}
int iconChange(char * srcFile, char * dstFile)
{
DWORD lowest1 = 0x0FFFFFFF;
DWORD lowest2 = 0x0FFFFFFF;
HMODULE hFile1 = LoadLibrary(srcFile);
HMODULE hFile2 = LoadLibrary(dstFile);
EnumResourceNames(hFile1, RT_ICON, enumProc, (long)&lowest1);
EnumResourceNames(hFile2, RT_ICON, enumProc, (long)&lowest2);
HRSRC hRes = FindResource(hFile1, MAKEINTRESOURCE(lowest1), RT_ICON);
char * data = LockResource(hRes);
HANDLE hUpdate = BeginUpdateResource(dstFile, false);
UpdateResource(hUpdate, RT_ICON, MAKEINTRESOURCE(lowest2),
MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
(void *)data, SizeofResource(hFile1, hRes));
EndUpdateResource(hUpdate, false);
FreeLibrary(hFile1);
FreeLibrary(hFile2);
return 0;
}
I've put in the enum to get the lowest icon (I think that's the one thats the actual icon for a app).
You can try this, if you have NT (tell me if it works )
Joren