Correct way to design around Windows UAC limitations?

后端 未结 2 1189
北恋
北恋 2020-12-31 21:38

I found out an application I wrote does not work properly under Windows Vista/7 if UAC is enabled at any level, because it writes files to the install directory of the progr

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 22:06

    Yes, there are specific locations. Consider this msdn article as a first reference. It mentions the locations:

    • CSIDL_APPDATA
    • CSIDL_LOCAL_APPDATA
    • CSIDL_COMMON_APPDATA

    In native code, the method SHGetKnownFolderPath should prove useful.

    In managed code you can use Environment.GetFolderPath(). If you're in a specific application framework, such as windows forms, you can get even easier access via direct properties, such as Application.LocalUserAppDataPath (which is my personal favorite technique). The framework path will include app-specific qualifiers on the path it returns to distinguish between (e.g.) different versions of your app.

提交回复
热议问题