简体   繁体   中英

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.

What is the difference between these two types?

I am asking this question specially for ANSI C.

It is right that DWORD is uint type and HANDLE is PVOID , and C allows to cast directly DWORD to HANDLE . 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:

  • DWORD 32 bit unsigned long
  • HANDLE void * (32 bit pointer)

Win64

  • DWORD 32 bit unsigned long
  • HANDLE void * (64 bit pointer)

DO NOT just assume you can cast one to the other. It will work for Win32 and break when you port it to Win64.

A HANDLE is a PVOID or a void* typedef, A DWORD is a uint32. Isn't a void* length depending from the memory architecture (eg. x86 & x64)?

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