Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DWORD datatype

Status
Not open for further replies.

hoojar

Programmer
May 26, 2005
14
GB
hi,

what is a DWORD datatype used for?
 
DWORD is not a standard C datatype. Typically it represents a double word. On a 16-bit machine a WORD would be 16 bits, on a 32-bit machine, it would be 32 bits.

Having said that, it would imply that a double word on a 16 bit machine is 32 bits and on a 32 bit machine, it would be 64 bits. However, that is very vendor dependent. If you use the 32-bit Microsoft compilers, a WORD and DWORD are the same size!!!

Since it deals with words, it is meant for low level use for instance bit patterns on an IO chip. If you want high level usage, use unsigned long.
 

thanks for the quick response.

i'm trying to work with the windows registry and i keep finding it in bits of sample code, it looks like it's being used as a counter.
 
For windows (9x, ME, 2K & XP) registry a DWORD is a 32-bit unsigned long.

I don't know about Vista or any of the 64 bit variants.
 
i'm using vista and it says dword is a 32 bit value and qword is a 64 bit. i've not used the registry before but it looks like dword is where i would store any numeric values, is that right? i can't see any other suitable types.
 
That's right, DWORD registry entries are used to store numbers.
 
xwb, can you prove this "If you use the 32-bit Microsoft compilers, a WORD and DWORD are the same size!!!" ? as far as I've checked, WORD is always unsigned short, which is 16bit, and never 32bit..

------------------
When you do it, do it right.
 
Look in WinDef.h:
Code:
typedef unsigned long DWORD;
typedef unsigned short WORD;
 
cpjust - you just proved him wrong. And I asked him to prove himself right. short is 16bits.. at least on Microsoft platforms.. be it 16bit, 32bit or 64bit platforms or compilers.

------------------
When you do it, do it right.
 
Some addition (don't forget): C (and C++) standards define int range via the natural size suggested by the architecture of the execution environment (but at least 16 bit). Moreover, long and short int types may be equal to the plain int.
The DWORD type (alias) is defined as a member of Windows Data Types set:
DWORD - 32-bit unsigned integer.
I think, the right answer is (a sort of;):
DWORD is MS Windows environment implementation defined integer type alias used in Windows API context only (and nowhere else;).
 
Apologies - I got confused between WORD and WPARAM. WPARAM and LPARAM which are used in the SendMessage call are both 32 bits. WPARAM used to be 16 bits on win3.x.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top