Reputation: 31
I Need help. I want to set correctly association file in windows 8. I have a program written MFC C++. It's .txt viewer. And I try associated file for current user. I create installer for my application and i can set my application as default, but it's doesn't work in windows 8.
What need to using? Thx.
Upvotes: 2
Views: 1129
Reputation: 1228
In Windows 8 there is only one way to do this. You should add your app to Defaults Applications. Then use Default Programs to ask an user to set associations. Unsure the old way with registry editing now is not availabled. In Windows 8 was added Hash variable to UserChoice registry key. It is unique for user and app. If it is wrong YourAppName is not be started by default but Windows 8 ask to choose application.
Short instruction how to add app to Default Programs. Full guide there http://msdn.microsoft.com/en-us/library/windows/desktop/cc144154%28v=vs.85%29.aspx Add to registry
key: "HKLM\Software\RegisteredApplications" name: "YourAppName" value: "Sofware\YouCompany\YourAppName\Capabilities"
key: "HKLM\Sofware\YouCompany\YourAppName\Capabilities" name: "ApplicationDescription" value: "just a description"
key: "HKLM\Sofware\YouCompany\YourAppName\Capabilities" name: "ApplicationName" value: "YourAppName"
key: "HKLM\Sofware\YouCompany\YourAppName\Capabilities\FileAssociations" name: ".txt" value: "Progid.txt"
Now YourAppName added to Default Programs
Need to call dialog with application file associations. It can be done with IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI http://msdn.microsoft.com/en-us/library/windows/desktop/bb776329%28v=vs.85%29.aspx
IApplicationAssociationRegistrationUI *applicationAssociationRegistrationUI = 0;
CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
0,
CLSCTX_INPROC_SERVER,
IID_IApplicationAssociationRegistrationUI,
(LPVOID*)&applicationAssociationRegistrationUI);
if (applicationAssociationRegistrationUI)
applicationAssociationRegistrationUI->LaunchAdvancedAssociationUI(L"YourAppName");
Upvotes: 2