WinAPI 中定义的 DWORD 与程序集中定义的 DWORD 相同吗

发布于 12-16 00:04 字数 189 浏览 5 评论 0原文

在WinAPI中:

typedef unsigned long DWORD;

我认为DWORD、WORD...是计算机中的基本数据类型,无论int、unsigned long...最终在汇编中都会转换为DWORD,为什么这里要转换为unsigned long?不加定义就不能直接使用DWORD吗?

in WinAPI:

typedef unsigned long DWORD;

I think DWORD, WORD ... is the basic data type in computer, for no matter int, unsigned long... it will be converted to DWORD finally in assembly, why should it be converted to unsigned long here? Can't I use DWORD directly without the difinition?

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

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

发布评论

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

评论(2

魄砕の薆2024-12-23 00:04:19

DWORD 是它定义的任何内容(汇编中不会自动转换为特定宽度)。需要此 typedef,因为无论使用 DWORD,WinAPI 接口都是用无符号长整型定义的。 IOW,您需要此定义才能使用 API。

回答你的另一个问题。这个答案是否定的,没有定义就不能使用DWORD。它不是编译器的内置类型。

Win32 API 的 DWORD 定义是固定的: http:// /msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx

DWORD is whatever it is defined to be (there is no automatic translation to a specific width in assembly). This typedef is needed because the WinAPI interfaces are all defined with unsigned longs wherever DWORD is used. IOW, you need this definition in place to work with the API.

To answer your other question. This answer is no, DWORD can't be used without a definition. It isn't a built-in type for the compiler.

The definition of DWORD is fixed for the Win32 API: http://msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx

那一片橙海,2024-12-23 00:04:19

在 Windows API 和基于 x86 指令集的汇编语言中,DWORD 指定大小为 32 位的变量。所以是的,它通常是相同的尺寸。

如果没有定义 DWORD 类型,则无法在 C++ 中使用它,因为它不是核心语言的一部分。 DWORD 的类型定义可能需要根据您的编译器和系统架构进行调整。显然,对于您的配置,unsigned long 类型有 32 位,因此 DWORD 被定义为 unsigned long

In the Windows API and in assembly languages based on the x86 instruction set, DWORD designates a variable with a size of 32 bits. So yes, it usually is the same size.

You can't use the type DWORD in C++ without defining it because it is not part of the core language. The type definition of DWORD may need to be adjusted depending on your compiler and system architecture. Apparently, for your configuration, the type unsigned long has 32 bits, so DWORD is defined as unsigned long.

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