"Hans Leidekker" hans@it.vu.nl wrote:
What do you propose then? I could do something like this:
if (GetLastError()==(DWORD)NTE_BAD_KEYSET)
But I consider a cast even uglier then introducing an intermediate variable. We somehow have to live with the fact that NTE_BAD_KEYSET is defined as ((HRESULT)0x80090016L), which is signed, and GetLastError() returning DWORD, i.e unsigned.
I propose a simple solution - just ignore warnings in these cases. Win32 is not an API which you could safely compile with signed/unsigned comparison warnings turned on, there are huge amount of cases when an API receives an unsigned int as a string length but returns signed int as a resulting length, and vice versa. There is no any consistency with passing/returning buffer lengths in Win32 at all, sometimes it's DWORD, sometimes UINT, sometimes just int. And that's just a couple of examples.