Windows API for VISTA, 7 &超过 [英] Windows API for VISTA, 7 & Beyond

查看:24
本文介绍了Windows API for VISTA, 7 &超过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WinAPI/Win32 有什么根本区别吗?要利用新的操作系统功能,是否需要额外的知识?

Is there any fundamental differences in the WinAPI/Win32? Is there any additional knowledge required to take advantage of new OS features?

过去编写 Win32 应用程序的人是否会陷入任何陷阱?

Are there any pitfalls which someone who's coded Win32 apps in the past might fall in?

我不是在谈论 Silverlight,那是一个完全不同的蜡球.(我还没有在工作中支持它的 VS.)

I'm not talking about Silverlight, that's a whole different ball of wax. (I don't have the VS that supports that at work yet.)

到目前为止,德鲁有一个很好的答案,但是程序员知道什么是关键?即Charles Petzold的书的附录应该是什么?(理论上)

Drew has a pretty good answer so far, but what's critical for a programmer to know? i.e. What should be in an appendix to Charles Petzold's book? (Theoretically)

推荐答案

当然,您应该了解许多新的 API,以确保您拥有所需的工具.除此之外,还有一些变化需要注意.

There are of course lots of new APIs that you should be aware of to make sure you have the tools you need. Beyond that, there are some changes to note.

理念变化
旧的 win32 API 的大部分集中在传递句柄的 C 样式 API 上.如今,正在开发的许多新 API 都是基于 COM 的,因此对 COM 和 ATL 进行深入研究是值得的.

Philosophical changes
Large parts of the old win32 APIs focused on C-style APIs where handles were passed around. Nowadays, many of the new APIs being developed are COM-based, so boning up on COM and ATL would be worthwhile.

如果您正在编写自己的库,您可能还需要注意新的 API 样式,这会更加一致并且避免使用匈牙利符号之类的东西.

You might also want to take note of the new API style if you're writing your own libraries, which is a bit more consistent and avoids things like hungarian notation.

替换
一般来说,不要假设你大约 10 年前知道的方法仍然是最先进的;它们都仍然存在,所以你不一定会被告知你做错了.检查 MSDN 以查看它是否为您提供更好的东西,并使用最新的 SDK,以便您收到某些功能的弃用警告.尤其要确保您使用的字符串函数是安全的.

Replacements
Generally, don't assume that the methods you knew about 10 years ago are still state-of-the-art; they all still exist, so you won't necessarily be told you're doing it wrong. Check MSDN to see if it refers you to something better, and use the latest SDK so that you'll get deprecation warnings for some functions. Especially, make sure string functions you're using are secure.

具体来说,一个替代"API 是 Direct 2d,它是用于 UI 的 DirectX 样式 API.如果您正在为 Windows 7 编写图形代码,您应该考虑通过 GDI 使用 Direct2d,它具有与 GDI 兼容但与 GDI 非常不同的编程模型.Direct 2d 可能会移植回 Vista.

Specifically, one 'replacement' API is Direct 2d, which is a DirectX-style API for UIs. If you're writing graphics code for Windows 7, you should consider Direct2d over GDI, which has a programming model that is compatible with, but very different than, GDI's. Direct 2d may be ported back to Vista.

此外,不要使用 win32 样式的菜单,而应考虑使用 Ribbon,它适用于 Vista 和 Win7.

Also, instead of using win32-style menuing, consider using the Ribbon, which will be available for Vista as well as Win7.

如果您使用的是通用控件库,请确保使用 v6,而不是 v5 的默认值.

If you're using the common controls library, make sure to use v6, not the default of v5.

最后,请确保您没有不必要地调用需要管理员权限的东西,因为这会提示 UAC.

Finally, make sure you're not unnecessarily calling things that require admin privileges, as that will prompt UAC.

暂时想到这么多.

这篇关于Windows API for VISTA, 7 &超过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆