简体   繁体   中英

Porting C++ Application From XP to Vista/7

I have a C++ application that I have written for Windows XP, and I would like to port it for use on Windows Vista/7. It uses some MFC (for serial I/O) and ATL (for WMI), but it primarily uses the good ol' fashioned Windows API. What are some of the got-yas I should keep in mind when porting my application? Thanks.

You probably don't need to do anything at all. In general, applications written for XP run fine on Vista and Windows 7. (Device drivers and other such low-level code may be a different story.)

Are you having problems running it on Vista or Windows 7? Have you even tried?

Some possible gotchas:

  • security (does your app assume it is running as Administrator and has complete control over the machine?)
  • cosmetic issues (due to changes in window and control appearance in Vista and 7)
  • hard-coded file/directory paths
  • a lot more users run 64-bit versions of Windows Vista and 7 than ever used 64-bit XP. So if you have a 32-bit app and you dynamically load code (DLLs, ActiveX controls, etc.), you may run into 32-vs.-64-bit issues.

The Application Compatibility Toolkit will help you spot issues your application might have porting to Vista/Win 7:

http://www.microsoft.com/downloads/en/details.aspx?familyid=c4a25ab9-649d-4a1b-b4a7-c9d8b095df18&displaylang=en

I'd second Michael Burr's suggestion to use the AppCompat toolkit, as that will spot most of the likely problems. Some general rules of thumb:

  • Don't write data to HKLM aside from in the installer. Use HKCU. Any read/writes to HKLM may be virtualised and you may get very strange behaviour when switching between user accounts
  • Don't use hardcoded paths, use SHGetFolderLocation
  • Don't write data to system areas such as c:\\windows , c:\\program files , etc. If you do need to write data that has to be available to all users, use CSIDL_COMMON_APPDATA ( c:\\ProgramData by default)

Assuming that you do most of these things right anyway then I would think you won't have any major issues supporting Vista/Win7.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM