Recently one of my clients has asked me to change the default program associated with the extension . pdf to Acrobat Reader DC on Windows 10, all in an automated way. The first thing that comes to mind is to change it through the registry by editing the registry key UserChoice.
Hash entry that is generated automatically by Windows to validate the integrity of file type association.
ProgId entry is the Registered Application Id that handle the file type.
The main problem is that in recent versions of Windows 8/10 This key is protected by a hash associated with the file type, and succeeding in editing it without generating the valid hash the association is automatically restored to the default application.
Doing a quick search on Google I found some ways to do it, using GPO(Group Policy Object) or importing a .xml association file with DISM.exe, but they were a little extensive processes, after a deeper search and taking into account that my client needed a quick fix I found this little command line tool SetUserFTA.exe created by Christoph Kolbicz which complied with what was required and I opted to use momentarily, however I was intrigued to be able to include this method directly in an application developed in another language such as C++, AutoIt, Pascal or PowerShell.
After a couple of days fighting against Windows, and using a little reverse engineering I manage to find the method that uses Windows internally and develop a code to implement in the application of my client.
I developed a small command line tool in PureBasic to perform this task over Windows 8/10 which is very simple to use.
Set Acrobat Reader DC as Default .pdf reader:
SFTA.exe AcroExch.Document.DC .pdf
Set Sumatra PDF as Default .pdf reader:
SFTA.exe Applications\SumatraPDF.exe .pdf
I hope this tool will be useful.