移植 C++应用程序从XP到Vista/7

发布于 2024-10-06 23:05:11 字数 144 浏览 8 评论 0原文

我有一个为 Windows XP 编写的 C++ 应用程序,我想将其移植到 Windows Vista/7 上使用。它使用一些 MFC(用于串行 I/O)和 ATL(用于 WMI),但它主要使用良好的老式 Windows API。移植应用程序时我应该记住哪些注意事项?谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无所的.畏惧 2024-10-13 23:05:11

您可能根本不需要做任何事情。一般来说,为 XP 编写的应用程序在 Vista 和 Windows 7 上运行良好。(设备驱动程序和其他此类低级代码可能是另一回事。)

您在 Vista 或 Windows 7 上运行它时遇到问题吗?你尝试过吗?

一些可能的问题:

  • 安全性(您的应用程序是否假设它以管理员身份运行并完全控制机器?)
  • 外观问题(由于 Vista 和 7 中窗口和控件外观的变化)
  • 硬编码文件/目录路径
  • 更多用户运行64位版本的Windows Vista和7比以前使用64位XP的用户多。因此,如果您有 32 位应用程序并且动态加载代码(DLL、ActiveX 控件等),则可能会遇到 32 位与 64 位问题。

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.
趴在窗边数星星i 2024-10-13 23:05:11

应用程序兼容性工具包将帮助您发现应用程序移植到 Vista/Win 7 时可能遇到的问题:

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

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

呆萌少年 2024-10-13 23:05:11

我赞同 Michael Burr 的建议,即使用 AppCompat 工具包,因为这会发现大多数可能的问题。一些一般经验规则:

  • 除了安装程序之外,不要将数据写入 HKLM。使用香港大学。对 HKLM 的任何读/写都可能是虚拟化,您可能会感到非常奇怪在用户帐户之间切换时的行为
  • 不要使用硬编码路径,请使用 SHGetFolderLocation
  • 不要将数据写入系统区域,例如 c:\windowsc:\program files 等。如果确实需要写入必须可供所有用户使用的数据,请使用 CSIDL_COMMON_APPDATA (默认情况下 c:\ProgramData

假设您无论如何都正确执行了大部分这些操作,那么我认为您支持 Vista/Win7 不会有任何重大问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文