Queries I tried: ExpandEnvironmentStrings("%COMMONPROGRAMFILES%")
, GetSpecialPath(CSIDL_PROGRA开发者_如何学PythonM_FILES_COMMON)
.
All resolve to (typically) c:\\Program Files (x86)\\Common Files
from my 32-bit app. I need to check a file version installed (typically) under c:\\Program Files\\Common Files
of a 64-bit application.
On 64-bit operating systems, the ProgramW6432 environment variable points to c:\program files. The full list for a 32-bit app on an English version of Windows:
- ProgramFiles => c:\program files (x86)
- ProgramFiles(x86) => c:\program files (x86)
- ProgramW6432 => c:\program files
- CommonProgramFiles => c:\program files (x86)\common files
- CommonProgramFiles(x86) => c:\program files (x86)\common files
- CommonProgramW6432 => c:\program files\common files
Just a reminder: that folder should not contain anything of interest to a 32-bit program. Technically. Beware of the file system redirector, it will redirect file requests from c:\program files to c:\program files (x86). You'd have to use Wow64DisableWow64FsRedirection() if you'd actually wanted to access files in that directory.
%CommonProgramW6432%
static string ProgramFilesx86()
{
if (8 == IntPtr.Size
|| (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
{
return Environment.GetEnvironmentVariable("ProgramFiles(x86)");
}
return Environment.GetEnvironmentVariable("ProgramFiles");
}
Is this what you're needing?
精彩评论