我使用的是:
FileInfo(
System.Environment.GetFolderPath(
System.Environment.SpecialFolder.ProgramFiles)
+ @"MyInstalledApp"
为了确定一个程序检测到用户计算机上(这是不理想,但我正在寻找的程序是一个MS-DOS应用程序的权利旧杂牌组装电脑,我想不出另一种方法)。
In order to determine if a program is detected on a users machine (it's not ideal, but the program I'm looking for is a right old kludge of a MS-DOS application, and I couldn't think of another method).
在Windows XP和32位版本的Windows Vista能正常工作。然而,在x64 Windows Vista中的code返回64 Program Files文件夹,而应用程序安装在程序文件86。有没有一种方法以编程方式返回的路径,程序文件86没有硬接线的C: Program Files文件(x86)的?
On Windows XP and 32-bit versions of Windows Vista this works fine. However, on x64 Windows Vista the code returns the x64 Program Files folder, whereas the application is installed in Program Files x86. Is there a way to programatically return the path to Program Files x86 without hard wiring "C:Program Files (x86)"?
推荐答案
下面的函数将返回86 程序文件
目录中的所有这三个的Windows配置:
The function below will return the x86 Program Files
directory in all of these three Windows configurations:
 
static string ProgramFilesx86()
{
if( 8 == IntPtr.Size
|| (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
{
return Environment.GetEnvironmentVariable("ProgramFiles(x86)");
}
return Environment.GetEnvironmentVariable("ProgramFiles");
}
相关推荐
最新文章