Combining the value of GetLastError and a custom error message

Posted by Jessica on Stack Overflow See other posts from Stack Overflow or by Jessica
Published on 2010-04-30T19:54:02Z Indexed on 2010/04/30 19:57 UTC
Read the original article Hit count: 174

Filed under:
|
|

I have a function that returns a different DWORD value for each case there is an error. So I have the following defines:

#define ERR_NO_DB_CONNECTION    0x90000
#define ERR_DB_NOT_OPEN         0x90001
#define ERR_DB_LOCKED           0x90002
#define ERR_DB_CONN_LOST        0x90003

Now, I return those values when an error occurs. I need to also return the value of GetLastError in the same return.

No, I can't read it later.

I tried combining it different ways, eg:

return ERR_DB_NOT_OPEN + GetLastError();

and then extract the error by subtracting the value of ERR_DB_NOT_OPEN but since I need to use this in functions where there can be several return values it can get quite complex to do that.

Is there any way to achieve this? I mean, combine the value + GetLastError and extract them later? Code is appreciated.

Thanks

Jess.

© Stack Overflow or respective owner

Related posts about c

    Related posts about Windows