Results 1 to 7 of 7

Thread: Environment Variable X86 x X64

  1. #1

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Environment Variable X86 x X64

    Hi

    My application it's targeting x86, the machine it's a x64. I need the common program files path for the current machine.

    But after expanding the commonprogramfiles var or commonprogramfiles(x86), or by using the special folder enum, in both situations it returns the x86 path...

    Code:
    ?Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)
    "C:\Program Files (x86)\Common Files"
    ?Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFilesX86)
    "C:\Program Files (x86)\Common Files"
    
    ?Environment.ExpandEnvironmentVariables("%commonprogramfiles%")
    "C:\Program Files (x86)\Common Files"
    ?Environment.ExpandEnvironmentVariables("%commonprogramfiles(x86)%")
    "C:\Program Files (x86)\Common Files"
    Why i cant get the "C:\Program Files\Common Files" ?!?!
    It's because of the target CPU?!

    Thanks

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Environment Variable X86 x X64

    It's because of the target CPU?!
    Well yes. Obviously. Your application is compiled to run entirely in the x86 environment so its special folders sites will all be x86 also. Why would you need to access 64-bit files from a 32 bit application anyway?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Environment Variable X86 x X64

    This application it's targeting the x86 to solve some issues with some componentes in x64 machines.
    But now i need to use the TabTip, and in the 64bits machines it's in the Common Program Files...

    How should i get the x64 common program files directory?

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  4. #4

    Re: Environment Variable X86 x X64

    If TabTip is x64 then...referencing with 32 bit would cause a crash! I'm not sure what on earth you're trying to do, but .NET is probably trying to prevent you from shooting yourself in the foot!

  5. #5

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Environment Variable X86 x X64

    The TabTip has two versions, 32 bit version located at common program files x86, and the 64 bits version located at common program files. I don't know if it's the same file, i just know that they are in separeted dirs.

    Now i need to call the tabTip keyboard, that in a windows 7 x64 it's localted in common program files, but trying to get this directory with the ambient variable, it's impossible because it returns me the common program files (x86).

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Environment Variable X86 x X64

    Why do you need to look for it at all? TabTip is an auto start service so it should be in running processes. Not that I know how you'd interact with it but you certainly shouldn't need to be starting it from the .exe which is what I presume you're attempting?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Environment Variable X86 x X64

    This is not really a .Net issue, this is how Windows works. A 32-bit application can not reach the 64-bit environment (not even within the file system). If you try to access Windows\System32 you will actually look into the folder Windows\SysWow64 and even if you hard coded the path to the Program Files folder you would still end up in the Program Files (x86) folder. This is how the Windows On Windows sub system works. So you can't reach the folder simply because from the perspective of the running process it just doesn't exist.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width