RomanM
RomanM

Reputation: 6711

SendMessage API in 64 bit

According to MSDN

The return value specifies the result of the message processing; it depends on the message sent.

I know it is defined as

typedef LONG_PTR LRESULT;

Meaning it will be 8 bytes on 64bit machine but it doesn't!

Does anyone know if it is safe to assume that only the lower 4 bytes are used and store it as an INT (for example).

Upvotes: 0

Views: 2248

Answers (3)

MSalters
MSalters

Reputation: 179779

Definitely not safe. If the message return is indeed a pointer, it is very well possible for the pointer to have its 33rd bit set - especially on machines with >4GB memory.

Upvotes: 1

Maverique
Maverique

Reputation: 73

No it is not safe in general. Do not assume the downcast. Also, useful is to compile your code with /RTCc which ensures inadvertent casts are asserted at runtime.

Upvotes: 1

James Ogden
James Ogden

Reputation: 852

No it's not safe, because the return value is defined by the message being sent and the handler.

If you control the handler and the message then it'd be possible, it's not safe in the general case.

James

Upvotes: 4

Related Questions