简体   繁体   English

C中DWORD和HANDLE类型有什么区别?

[英]What is the difference between DWORD and HANDLE type in C?

I have a thread with return type DWORD in C but it is then handled by a HANDLE type pointer. 我有一个在C中返回类型为DWORD的线程,但它由HANDLE类型指针处理。

What is the difference between these two types? 这两种类型有什么区别?

I am asking this question specially for ANSI C. 我特地针对ANSI C问这个问题。

It is right that DWORD is uint type and HANDLE is PVOID , and C allows to cast directly DWORD to HANDLE . DWORDuint类型而HANDLEPVOID是正确的,而C允许直接将DWORDHANDLE But is there any difference in these types or can I simply say they are the same? 但这些类型有什么不同,或者我可以简单地说它们是相同的吗?

It is a question that was asked during a discussion. 这是一个在讨论中提出的问题。 I want to know what the right answer is. 我想知道正确答案是什么。

Win32: Win32的:

  • DWORD 32 bit unsigned long DWORD 32位无符号长
  • HANDLE void * (32 bit pointer) HANDLE void *(32位指针)

Win64 Win64平台

  • DWORD 32 bit unsigned long DWORD 32位无符号长
  • HANDLE void * (64 bit pointer) HANDLE void *(64位指针)

DO NOT just assume you can cast one to the other. 不要只是假设你可以将一个投射到另一个。 It will work for Win32 and break when you port it to Win64. 它将适用于Win32并在您将其移植到Win64时中断。

A HANDLE is a PVOID or a void* typedef, A DWORD is a uint32. HANDLE是PVOID或void * typedef,DWORD是uint32。 Isn't a void* length depending from the memory architecture (eg. x86 & x64)? 取决于内存架构(例如x86和x64),不是void * length吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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