Home > Windows Server Tips > Windows Server Monitoring and Management > Run 32-bit applications on x64 Windows servers
Windows Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

WINDOWS SERVER MONITORING AND MANAGEMENT

Run 32-bit applications on x64 Windows servers


Brien M. Posey, Contributor
09.27.2006
Rating: -3.20- (out of 5)


Expert advice on Windows-based systems and hardware
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


The x64 version of Windows is not capable of natively running 32-bit code. Because most applications are 32-bit, the x64 version of Windows makes use of an emulator known as WOW64 to allow 32-bit applications to run.

One of the problems with running 32-bit code on a 64-bit operating system is that the OS must maintain complete code separation. Microsoft has created a new folder named \Windows\SysWOW64 that is used to store the 32-bit DLLs. In the 32-bit version of Windows, DLL files are normally stored in the \windows\system32 folder. However, the x64 version of Windows uses the \windows\system32 folder for 64-bit DLLs.

As you can see, the WOW64 emulator must perform file system redirection in order to guarantee that 32- and 64-bit code remain separated. But keeping DLL files separated is only the beginning. The WOW64 emulator performs file system redirection for several key components of the Windows operating system.

Another location in Windows where file system redirection is used is the Program Files folder. Almost every application you install it gets installed to the C:\Program Files folder. Because each application is installed in a separate subfolder, the Program Files folder seems like an unlikely target for file system redirection. However, in the x64 version of Windows, only 64-bit applications are usually installed in the Program Files folder -- 32-bit applications are installed in a folder named Program Files (x86).

However, the Program Files folder may not always be in the same place on every computer. I have seen deployments (admittedly few and far between) in which Windows was installed on a secondary hard drive. As such, most application developers do not hard-code the c:\Program Files path into applications. Instead, Setup programs usually make a call to an OS function known as SHGetSpecialFolder() in order to determine the exact name and location of the Program Files folder. Although this bit


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
64-bit Architecture for Windows
Getting familiar with 64-bit technology
64-bit technology: What it means for your favorite apps
Give your system memory a boost with x64
Virtualization and 64-bit: A match made in Windows heaven
Can Active Directory benefit from 64-bit technology?
Can 32-bit and 64-bit domain controllers co-exist?
Can I install Exchange 2003 on a 64-bit machine and upgrade it to Exchange 2007?
When and how to migrate to a 64-bit platform
64-bit Windows – help or hype?
Multi-core CPUs, x64 servers advance server consolidation efforts

Windows Server Monitoring and Management
Simple tools and techniques for finding Windows memory leaks
Top Windows server hardening standards and guidelines
Hyper-V gains new resiliency features with Windows Server 2008 R2
Troubleshooting Windows print spooler crashes
Windows server hardening: How much is enough?
Terminal Services grows up with Windows Server 2008 R2
Top five Server Core management tips for Windows 2008
Windows Server 2008 R2: Not your father's R2 upgrade
The bottom line on Microsoft Hyper-V
Does Microsoft Hyper-V fit in the dynamic data center?

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


of information may seem trivial, it is useful in making sure that applications are installed to the correct folder.

In the 32-bit version of Windows, the SHGetSpecialFolder() function is used to determine the name and location of the Program Files folder. But in the x64 version, the function looks at whether the Setup application was running 32- or 64-bit code and performs folder redirection based on that application.

Application installation is not the only time when the Program Files folder is referenced; it may also be referenced during application run time. Although there are several ways that an application can determine the name and location of the Program Files folder, environment variables are often used. In a 32-bit version of Windows, the %ProgramFiles% environment variable contains the path to the Program Files folder. In an x64 version of Windows, this environment variable is still used, but it works differently.

The most important rule of the x64 platform is that you absolutely cannot mix 64- and 32-bit code. Environment variables are often called from within scripts. That being the case, running scripts can get a bit tricky in a 64-bit environment. Should Windows treat the script as 32-bit code or as 64-bit code? The answer affects not only the contents of the environment variables, but also which external programs the script can call. For example, a 64-bit script can't launch a 32-bit process (at least not in the usual way).

Windows gets around these issues by offering two command prompts: one 64-bit and one 32-bit. Environment variables are set according to which command environment is being used.

For example, if you open a command prompt by entering the CMD.EXE command at the Run prompt, Windows will open a 64-bit command prompt. In most cases, the %ProgramFiles% environment variable for the command environment will be set to C:\Program Files. If you run a script, the script can interact with 64-bit applications, but not with 32-bit apps.

On the flip side, if you enter the C:\Windows\SysWOW64\cmd.exe command at the run prompt, you'll be running a 32-bit command prompt. In that case, the %ProgramFiles% environment variable will be set to C:\Program Files (x86).

As you can see, the location of the Program Files folder is redirected depending on whether you're running 32- or 64-bit code. But there's one exception to this rule. If an application has the C:\Program Files path hard-coded, then C:\Program Files will be used, even if the application is made up of 32-bit code. Folder redirection does not occur for hard-coded paths. Fortunately, hard-coding paths is not a common programming practice.

About the author: Brien M. Posey, MCSE, is a Microsoft Most Valuable Professional for his work with Windows 2000 Server, Exchange Server and IIS. He has served as CIO for a nationwide chain of hospitals and was once in charge of IT security for Fort Knox. He writes regularly for SearchWinComputing.com and other TechTarget sites.

More information on this topic:

Rate this Tip
To rate tips, you must be a member of SearchWindowsServer.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Server Room Design - Planning, Cooling, Maintenance
HomeTopicsBlogsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2004 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts