'How to assign an icon to a file?

I am making a program that stores information in a file with a custom extension. I was wondering If it is possible to assign it an icon within the program so that the icon will show the file with the icon anywhere on the computer? For example how all Microsoft word documents have the word icon.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source