Skip to main content
GameDev.net gamedev.net
🔒 Locked

Wanna explain LOWORD, HIWORD, DWORD?

Started by Gollum Jun 23, 2000 at 12:14 PM 13 replies 16.3k views
Original Post
Gollum
Gollum
Hey guys, Newbie programmer here, working through the Lamothe book with _no_ C++ experience. Sometimes he glosses over the C++ background to this stuff, and I can''t find a good explanation anywhere (in his book, on the net, in the DX SDK help, etc.) of what the heck a LOWORD and a HIWORD are. I''m pretty sure that I''ve seen the terms DWORD and just plain WORD floating around, too. This doesn''t have anything to do with rap, does it? Word. Peace, yo. - gollum
neonstar
neonstar
yo homeboy, lemme bust my rhyme about dis, WORD!

basically, DWORD is some form of integer value. i think it''s something like an unsigned int, but someone correct me of i''m wrong. all HIWORD and LOWORD are are just variable types that windows uses to pass window message values to winAPI functions. or maybe not... hell i dunno, i can''t even believe myself lately...



i love leaving people in the dark...
(or is it that i''m completely unsure of my answer...)

david
--david@neonstar.netneonstar enter
ImmaGNUman
ImmaGNUman
HIWORD and LOWORD retreive the value of the HIWORD and LOWORD. Windows sometimes passes two values with 1 variable, HI and LO are where they are stored in the bits.

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
ECKILLER
ECKILLER
LOWORD and HIWORD are macros. LOWORD gets the lower 16 bits of a 32 bit integer and HIWORD gets the upper 16 bits. the wParam and lParam give you information about a particular message. This way wParam or lParam can give two pieces of information per pop. It can store one piece in the lower word and another piece in the hiword. So to reiterate LOWORD and HIWORD are macros that return the lower 16 bits of higher 16 bits of a 32 bit lParam or wParam.

I did this off the top my head so may not be 100% right.

ECKILLER
ECKILLER
neonstar
neonstar
(whew, glad someone gave more info than I did.... )

david
--david@neonstar.netneonstar enter
Muzzafarath
Muzzafarath
quote:
Original post by neonstar

yo homeboy, lemme bust my rhyme about dis, WORD!

basically, DWORD is some form of integer value. i think it''s something like an unsigned int, but someone correct me of i''m wrong. all HIWORD and LOWORD are are just variable types that windows uses to pass window message values to winAPI functions. or maybe not... hell i dunno, i can''t even believe myself lately...



i love leaving people in the dark...
(or is it that i''m completely unsure of my answer...)

david


DWORD is usually a long. HIWORD and LOWORD are macros or functions.

- Muzzafarath

Mad House Software
The Field Marshals
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
asmLOCK
asmLOCK
A DWORD is a 32-bit integer, and with a WORD being a 16-bit integer, the HIWORD and LOWORD refer to their respective place inside the DWORD.

<---------------DWORD--------------->
[00000000:00000000:00000000:00000000]
<-----HIWORD-----><------LOWORD----->

I''ve never delt with "LOWORD"s and "HIWORD"s, but I''m heavily into assembly, and that''s what I''m guessing they mean.
Maybe I''m wrong, but I doubt it.


When life hands you lemons, throw them at God's head.
3dModelMan
3dModelMan
Starting from the beginning:

a BIT 0 or 1
a BYTE , made from eight bits. Can hold a value of 0 to 255
a WORD, made from 2 bytes (16 bits) can hold a value of 0 to 65535. The two bytes that make up a word are called LOBYTE and HIBYTE.

If you think of the LOBYTE as the smallest part of the number, the value of a WORD is equal to 256 * HIBYTE + LOBYTE. Therefore the HIBYTE describes how many 256''s we have, and the LOBYTE describes the rest. Such is the magic of binary.

a DWORD, (double word) made from 2 words. Again referred to as LOWORD and HIWORD.

Later

Matt





Check out my project at:www.btinternet.com/~Matthew.Bennett
Gollum
Gollum
I think I get the general idea. My problem is that I have to know where everything comes from.

So, let me see if I''ve got this right:

Message structures in Windows contain 32 bit integers, which for some reason are called DWORD.

There are C++(?) macros called HIWORD and LOWORD. These macros extract the first and second half of the DWORD, respectively. C++ uses those macros to get at the lparam and wparam that hold parameters for the messages.

Phew.

And this is just the beginning.

- gollum

PS - I really need to go back to Lamothe and see if he''s got the prototype for a message. Surely he does...
Gollum
Gollum
Doh! Matt beat me to it. That was the explanation I really needed. I think I needed to know if word and dword were Microsoft terms or part of a generic heirarchy, like you just showed.

Thanks, everyone! All of this, in less than an hour. I love this place.

Marsupial Rodentia
Marsupial Rodentia
Yeah, just wait til we all get to Win64 programming and then the newbies ask someone to explain what a QWORD (quadword) or an INT64 is

... or even a PARAGRAPH for you ASM junkies.

Edited by - Marsupial Rodentia on June 23, 2000 2:03:26 PM
baskuenen
baskuenen
Isn''t a PARAGRAPH 16byte alignment? Must take some more pills now...

When using 16bit environment:
int - 16bits
BYTE - unsigned char
WORD - unsigned (int)
DWORD - long (int)

When using 32bit environment:
int - 32bits
BYTE - unsigned char
WORD - unsigned short (int)
DWORD - unsigned (int)

frank_d
frank_d
Just one thing:
I think you said HIWORD and LOWORD were used to extract the lParam and wParam. Noooo. lParam and wParam are 2 different variables. You use LOWORD and HIWORD to extract 2 chunks of data from one of them. So lParam could store an x value in HIWORD and a y value in LOWORD. or something.
I''m guessing DWORD stands for double word, cos it''s 2 WORDs you see. WORD isn''t a microsoft term I don''t think.
Anyway, hope I havn''t shattered anyone''s new-found understanding with my mumblings.
Frank
Esap1
Esap1
A WORD is not Micro$ofts term, its just two bytes, and DWORD is a double WORD, as in 32bits(4 Bytes), as so many of you said
DarkMage139
DarkMage139
Yes, it does sound like rap...

Microsoft does have somewhat strange APIs anyway. Look at GDI!

- DarkMage139
"Real game developers don't change the rules. Real game developers don't break the rules. Real game developers make the rules!"
"Originality (in games) is the spice of life!"
DarkMage139

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.