开发者

How to use ShowHelp with Vista's virtualized "Program Files" folder

开发者 https://www.devze.com 2022-12-26 21:44 出处:网络
we have the problem that ShowHelp seems to fail under Vista and Windows Server 2008 if the path name of the help file contains a virtualized folder name.

we have the problem that ShowHelp seems to fail under Vista and Windows Server 2008 if the path name of the help file contains a virtualized folder name. For example, under the German version Vista, "Program Files" is called "Programme". The call

System.Windows.Forms.Help.ShowHelp(null, 
   @"C:\Programme\Microsoft Visual Studio 9.0\Common7\Tools\spyxx.chm");

fails, wheras

System.Windows.Forms.Help.ShowHelp(null,
   @"C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\spyxx.chm");

succeeds.

If there any way in C# to convert a file path into its non-virtualized cou开发者_开发百科nterpart?

Or is there any other solution to that problem?

Regards


It fails because C:\Programme isn't the real folder - it's just a displayed name. On Vista and 7, these folders ALWAYS have English names, regardless of OS language.

The right way is to look in the registry and see where it's installed. Look in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0 for the InstallDir key. This will be something like c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ if you have - tou can then manipulate this path to get to Common7\Tools instead.

In other words, simply don't hardcode the path.

If you must know the name of the Program Files folder, use GetFolderPath with the appropriate parameter instead of hardcoding it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号