Question: What is the equivalent of [INSTALLDIR] for %ProgramFiles(x86)% to use in Registry in 64 bit machine ?
I have a program that will be installed inside %ProgramFiles(x86)% in 64 bit machine.
Basically, I want to add these values in registry
Value name:
(Default)
Value data:
"C:\Program Files (x86)\MyApp\MyApp.exe" "%1"
The above Value data works just fine but I cannot use the exact path because the Windows might be installed in a different directory other than C:\
I tried
Value data:
"[INSTALLDIR]MyApp.exe" "%1"
but it gives application not found error.
What can I use to get the path of %ProgramFiles(x86)% in registry? Any help will be really appreciated.
Possibly duplicate here.
static string ProgramFilesx86()
{
if( 8 == IntPtr.Size
|| (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
{
return Environment.GetEnvironmentVariable("ProgramFiles(x86)");
}
return Environment.GetEnvironmentVariable("ProgramFiles");
}