tags:

views:

137

answers:

3

i have a thread with return type DWORD in c but it is then handled by a HANDLE type pointer,

what is difference between these two types?

ok 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 there types or i can simply say these are same

it is question asked during discussion i want to know what is the right ans????

A: 

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)?

chriszero
+1  A: 

If you're asking in the context of the Win32 API, then there is no substantive difference. A HANDLE is a 32-bit number, same as DWORD.

If you're asking in some other context (you have tagged this ansi-c for a reason?) then you will need to explain what context that is.

Greg Hewgill
+3  A: 

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.

Stephen Kellett