Programmatically add file association without admin rights in C#

送分小仙女□ 提交于 2019-12-10 18:52:25

问题


Other people have asked similar questions but I want to clarify. I want to build my application without the need for administrative permissions when installing. For the file association I understand that I need to write in the registry but so far I have found two different locations in stackoverflow articles:

HKEY_CURRENT_USER\Software\Classes

and another under

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts

So which is one the right one?


回答1:


You should use the former (HKCU\Software\Classes), because that's what Windows uses to open files.

I'm not sure what the second one is used for; I believe it's only used to populate the recommended section of the Open With dialog.




回答2:


Sadly this is not possible. You will need admin rights in order to do this, there is no way around that.

You can however let the user install the application without admin rights and give him the opportunity to associate the file extensions later on, where you would ask for elevated rights.

Besides that there is no way of accomplishing what you want.



来源:https://stackoverflow.com/questions/9705188/programmatically-add-file-association-without-admin-rights-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!