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.
views:
68answers:
1
Q:
What's the best way of getting the results of GetLastError() after a WinAPI call into a nice char* ?
+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
2009-10-23 13:30:54
Sounds like just the thing, thanks!
Benj
2009-10-23 13:31:54
Yup. That's how I do it. There's some example code here: http://www.codeproject.com/KB/tips/formatmessage.aspx
T.E.D.
2009-10-23 13:45:03