In this article, developers identify common problems in porting custom business applications to Windows 7 from Windows XP or Windows Vista, and in taking advantage of the OS’ new features. Why make your own mistakes when you can learn from others’ experiences? Find out where the bodies are buried.
My father-in-law once said that the best way to fix his old, broken-down car was to “Jack it up and drive a new one underneath.” Depending on the state of your software, that may be how you have to “update” an old Windows application: Replace it. One developer, Rob, has been trying to update a Windows XP Visual Basic 6 application for months and it’s turned into a complete rewrite. “We (foolishly, but we didn’t know better back then) used the registry for storing information, and the application always writes to the registry for all users. Not smart, but that’s how we did things back in the day,” he told me.
Before your company can migrate its computers to Windows 7, it has to make sure that all the business’ existing software will work with the new OS. Any custom application that crashes in Windows 7 testing will delay the migration, and if it was your code that crashed it might delay your vacation, too. (There’s nothing like getting a hairy eyeball from the boss, is there?) Even if your “legacy” code works fine under Windows 7 (ever notice that it’s “existing” code if they like it, but “legacy” when it’s too boring or expensive to maintain?), you might be called upon to do some code surgery, especially if someone sold the boss on adopting Windows 7 because of all it can do (from improved security to user interface improvements).
Rather than leave you on your own to figure out where the common problems are lurking, I asked for advice from those trying to make older applications work in Windows 7, and those who are updating older software to take advantage of Windows 7 features. Maybe this can save you from pain they endured.
I don’t mean to give the impression that code changes are always necessary. Several developers explained that software written for Windows Vista (and maybe Windows XP) generally runs without trouble in Windows 7. Plus, application migration isn’t always mission-critical because, say developers, the virtualization in XP-Mode does a good job. For instance, says Larry Zimbler, president of Liberteks.com, a real-estate client had an application that its manufacturer claimed would only work in Windows XP. The Windows 7 “Compatibility Mode” let it work without any extra effort. “This created great business value for the client,” says Zimbler. “She didn’t have to purchase a software upgrade and perhaps more importantly, all of her data and settings were restored exactly where she left off.” This is a boon for anyone supporting older applications. “Never before has the computer user had the flexibility of running old and new software as successfully,” Zimbler adds.
I only address custom applications in this article. Microsoft’s Windows 7 Compatibility Center lets you check on the compatibility status of commercial software applications.
At some point, though, you’ll want to make the software work the right way. Here’s a few things to look for.
Some of the pressure to fix applications is the result of the OS getting more efficient. Telecom developer Eduard Panteleev ran into trouble with a Windows XP application which uses lot of threads. The software would crash sometimes on Windows Vista (testing proved it to happen about once in 20 tries) when two application components were started at the same time. “With Windows 7, we were able to reproduce the issue once per three tries!” Panteleev says. The issue, he learned, was in bad architecture for one resource use by two or more threads. His conclusion is that Windows 7 is much better at managing threads and processes, particularly in comparison to Windows XP. That’s a good thing, overall (such as better CPU use) but it also means that dormant bugs may come back to bite you. “Now we are retesting our core product on Windows 7, even though our customers do not use Windows 7 yet,” says Panteleev.
Anil Parambath, VP of CSS Corporation’s Global Testing Practice identifies a few more complications:
- OS version changes. Some software checks for the operating system version number. You can generally work around these using shims. “A shim is a piece of code that sits between an application and the operating system that can intercept and modify how the application interacts with the OS,” Parambath explains.
- User security. Added security layers sometime restricts users to run as standard users or limits the context in which an application can execute. (Surely we can’t complain about the OS requiring developers to make their software more secure?)
- Session 0 issues. Before Windows Vista, says Parambath, all user application ran in Session 0. From Vista onwards, the user runs in Session 1, isolating all system services. This could pose problems if the application depends on interactive services, he points out.
In addition, says Parambath, many
.exe, and COM objects have been deprecated. Obviously, if your software depends on them, you may run into issues. Microsoft does supply several tools for compatibility testing, he says, many of which can assist in determining the problem with this particular computer. Among them are the User State Migration Tool (to migrate user profiles to a new operating system), the Windows 7 Upgrade Advisor (which scans the PC for compatibility issues with hardware and device driver support), and the Compatibility Administrator Tool (which might help a developer identify admin privilege issues).
Your compliance requirements may not be as stringent as an independent software vendor who wants to qualify for Microsoft’s logo certification, but I can’t imagine that adhering to those guidelines are a bad idea. Explains Nisha Sudarsanam, lead developer for MindManager for Windows at Mindjet, one condition for Windows 7 Logo Certification is making sure the application saves open documents and user-data and then shuts down immediately when forced to by the Windows 7 Restart Manager. “We saw cases where MindManager would not shut down and thus fail this certification test. Specifically, our C# add-ins that use the MindManager COM API had to be re-factored to correctly release the COM objects (using
System.Runtime.InteropServices.Marshal.ReleaseComObject instead of
System.Runtime.InteropServices.Marshal.FinalReleaseComObject).” It would be a good idea to check the Microsoft guidelines to see if your application responds correctly to the specific Windows Messages sent by the Restart Manager, says Sudarsanam.
Also, Sudarsanam’s team found that some Windows7 features introduced a new dependency on the Windows 7 SDK during the build process, but the same build had to continue to work on other older supported OSes (Windows XP/Windows Vista). “We got around this by dynamically loading libraries at run time and using a specific function in a Windows 7 DLL only if that DLL was loaded successfully. Thus we avoided a hard-dependency on Win7 DLLs at compile time,” Sudarsanam says.
MindJet is a C++ application, so Sudarsanam’s team had to do things differently from available code samples when it came to creating the thumbnail views of different MDI tabs within the application. “Basically, for each thumbnail view we created a
CWnd class that listened to special Windows 7 messages. On receiving this message, we then rendered the map in that tab in a small thumbnail-sized bitmap and then passed this thumbnail to the OS,” explains Sudarsanam. “This seems like the only approach to take if you want to support thumbnails in a C++ based MDI application.”
One important area of concern is less whether your application works with Windows 7, but whether it works with all versions. Andrew Badera, CEO of A Higher Efficiency, an Albany, NY based boutique tech consultancy, foresee developers struggling to move to 64-bit Windows. “Old projects need references updated, and strong-named assemblies need to be recompiled with the same key, or all strong-name references need to be edited,” Badera says. “It sounds silly and simple, but it’s actually a pretty big gotcha due to the way assembly binding issues don’t bubble up unless you’ve got Fusion fully logging assembly binds.”
Mindjet’s Sudarsanam probably would agree. Although MindManager runs as a 32-bit application on 64-bit computers, says Sudarsanam, “We needed to recompile a couple of DLLs in a 64-bit environment to get some features to work on 64-bit machines (e.g. our Windows search DLL that allows indexing of maps using Windows Search).”
If you’re lucky, your existing applications don’t need much or any help to run correctly under Windows 7, and your application testing project will confirm that the business’ custom applications are ready to be deployed. But if you’re going to write new software, shouldn’t it take advantage of the latest OS features?
Doing so might not be a big deal. Badera recently migrated some .NET applications for legal document auto-signing onto Windows 7 tablets (adding signature capture) from Windows XP and Windows Vista desktops. It was “nothing special” — which is what any developer wants to hear. “The taskbar gimmicks are really nothing special, and the rest of the development experience is akin to Vista (in terms of security manifest requirements and similar),” says Badera.
The flashier features may take a little more work, but the Windows development tools are prepared to make it easier for you to exploit those capabilities. Says Mike Rozlog, senior director of Delphi Solutions and technology evangelist for Embarcadero Technologies, having direct access to the Windows 7 native API can be very helpful. “In the latest Delphi and C++Builder 2010 editions, this corresponds to access to the Direct2D API/Interfaces. This gives the developers the ability to take full advantage of the canvas and manipulate it through a series of simple calls.”
The new features, such as Touch and Gestures, may require you to learn a few concepts first, however. Explains Rozlog, “Gestures are basic actions that can be performed by an input device, such as a mouse or finger. Common Gestures are flicking a finger to the right on the screen or flicking the finger to the left on the screen. Once these Gestures are performed and action must take place; think of it as the same process that happens when an end-user clicks a mouse, an action takes place after that.” Once you grasp Gestures, says Rozlog, Touch becomes just another input-device. But Rozlog has found many developers find the initial concepts hard to understand.
Once the understanding is there then Touch can be fairly simple. Mindjet’s Sudarsanam explains, “A lot of the Gesture support came out-of-the-box since Windows 7 maps the standard mouse events to gesture events, but we added a couple of custom gestures such as rotate for which we handled the new
“For Delphi, you need two basic components to implement Touch, a
GestureManager and an
ActionManager,” says Rozlog. “
GestureManager is a component that wraps the ability to create or use predefined gestures. Each Gesture (custom or standard) implements an Action,” he says. “The
ActionManager component manages all the defined actions, thus making it very simple to wire the ActionManager’s actions to the GestureManagers, Gesture, Action. Finally, Touch needs to be applied to the controls of the interface.” (Before you wonder: If Touch-enabled hardware is not available, Delphi Touch enablement is smart enough to use the Gesture manager through the mouse.)
Most business software developers are just getting started testing their applications to ensure compatibility with Windows 7 and to plan for new applications to exploit the new OS. But perhaps you’ve already run into a few “learning experience” situations, and found workarounds or solutions that are worth sharing. Tell us about them in the comments, to prevent other developers from working deep into the night, fueled only by pizza, beer, and a looming deadline.