views:

68

answers:

1

I'm writing a DLL which a java program uses to call the WinAPI in various ways. I want to throw proper exceptions back to java but I need a nicely formated WinAPI error not just the int that get's returned from GetLastError(). I'm sure there's a nice way to do it.

+5  A: 

Use "FormatMessage"; you can pass in the error code as the 3rd parameter, and even have FormatMessage allocate the space for you.

Joe
Sounds like just the thing, thanks!
Benj
Yup. That's how I do it. There's some example code here: http://www.codeproject.com/KB/tips/formatmessage.aspx
T.E.D.