How to return the x86 Program Files directory

.NET programming topics
Post Reply
Cyclops
Lieutenant
Lieutenant
Posts: 71
Joined: Wed Jul 15, 2009 1:48 pm
Location: London

How to return the x86 Program Files directory

Post by Cyclops » Thu Dec 31, 2009 8:49 am

This function will return the x86 Program Files directory in all 3 of the windows configurations

32 bit Windows
32 bit program running on 64 bit Windows
64 bit program running on 64 bit windows

Code: Select all


static string ProgramFilesx86()
{
    if( 8 == IntPtr.Size || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
     {
         return Environment.GetEnvironmentVariable("ProgramFiles(x86)");
     }
     return Environment.GetEnvironmentVariable("ProgramFiles");
}
Post Reply

Return to “.NET Programming”