问题
I am making a simple uwp text editor app. I want the app to open any kind of file even without file associations declared since there are many text files which don't have known extension in the os. Is there any way I can modify the registry to have my app available in Open-With list like notepad so user can open that file with my app from the file explorer itself??
回答1:
In Windows 10 2004 (build 19041) microsoft introduced uap10:FileType
attribute in package manifest and by providing *
as the value the app is available in open with menu of all types of files. To use this just add the following code to your manifest:
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
...
<uap:Extension Category="windows.fileTypeAssociation">
<uap:FileTypeAssociation Name="anyfile">
<uap:Logo>Assets\mylogo.png</uap:Logo>
<uap:SupportedFileTypes>
<uap:FileType>.txt</uap:FileType>
<uap10:FileType>*</uap10:FileType>
</uap:SupportedFileTypes>
</uap:FileTypeAssociation>
</uap:Extension>
This only works for Windows 10 build 19041 and above. The additional uap:FileType
is necessary if app targets minimum version below 19041 to pass manifest validation, otherwise it can be omitted.
回答2:
Great question, but I'm afraid you could not modify the registry to make the app available in Open-With list even without file associations declared within UWP app. And file association is only way to make the app could handle the file activation. Both Windows desktop applications and Universal Windows Platform (UWP) apps can register to be a default file handler. If you do want this feature please feel free post your requirement with windows feed back hub app.
来源:https://stackoverflow.com/questions/61059755/open-any-kind-of-file-with-an-uwp-app-without-file-association