I have no answer for Windows Explorer. For MacOS, the custom file icon is stored in the fileβs fork resource as kIconFamilyType with the identifier kCustomIconResource . The custom icon for the folder is stored in a file named Icon\r (\ r, meaning mac newline) in the folder. For volumes, the custom icon is located in the .VolumeIcon.icns file at the root of the volume. In each case, you must set the kHasCustomIcon Finder flag for the item.
Cocoa does not give you access to resource virtualization or Finder frames. Use FSSetCatalogInfo to set the Finder flags. Use FSCreateResourceFork, AddResource, and CloseResFile to add a custom icon family to the file. The same resource fork calls are used for the custom icon file in the folder.
The usual way to set an icon is to either paste it from the Get Info Finder window or send the apple event to the Finder. You can send Apple events from cocoa, but that will not help with the iPhone.
To create a file on the iPhone with a fork resource, you probably have to create a zip archive that will create a resource fork when unpacking. You will have to manually create a wrapper for the resource fork around the data in the icon family. The resource resource structure is well documented.
It would probably be easier to have a helper application on MacOS.
source share