
As far as I know there is no official API to do this (I just add proper keys to registry).
I implemented this functionality in NSIS. It works (in most cases).
Here is the example installer that offer pinning and unpinning folder icon.
Note, that I create keys for 32 bit and 64 bit OS. In 64 bit I need to add keys to 32 bit and 64 bit registry - that 64bit applications and 32 bit applications has access to this folder.
However, sometimes unpining action doesn't work 🙁
I have to manually remove keys from registry (it is easy, as we have our unique GUID).
It seems that it is not removing the keys - so Windows Explorer displays folder, but can not be accessed (or blank file).
Could you please take a look? Maybe I forgot about something? Or maybe I implemented it in wrong way...
The idea is to get fast access to chosen folder via Windows Explorer This PC View.
Example folder is C:\ThisPCTest
I use also example icon for the folder (\ThisPCIcon.ico)

It should look like this after Pin action:

I use ${RefreshShellIcons} after pin/unpin action - Should I use other code to refresh
Windows Explorer shell?
-Pawel