Packaging Values in Dword

How would I package two unsigned short (WORD) values into one unsigned long (DWORD) value?

I know how to get them using HIWORD and LOWORD macros but is there a ... sort of reverse macro for storing them into a DWORD quickly?

I'm programming in C++ with Microsoft Visual Studio 2012 IDE.

3 Answers

MAKELONG takes two WORDs and combines them into a single DWORD:

DWORD MAKELONG(
  WORD wLow,
  WORD wHigh
);

No idea why it isn't called MAKEDWORD...

0

Something like:

 DWORD x = (lo) | (hi << 16);

should do it.

2

What about this MAKELONG macro?

DWORD MAKELONG(
  WORD wLow,
  WORD wHigh
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest