add win32_throw_error function

This commit is contained in:
Doug MacEachern 2005-06-27 04:22:36 +00:00
parent 9e79ac3d83
commit 73eed8b1c7
2 changed files with 8 additions and 1 deletions

View File

@ -21,13 +21,18 @@ void win32_throw_exception(JNIEnv *env, char *msg)
} }
void win32_throw_last_error(JNIEnv *env) void win32_throw_last_error(JNIEnv *env)
{
win32_throw_error(env, GetLastError());
}
void win32_throw_error(JNIEnv *env, LONG err)
{ {
char msg[8192]; char msg[8192];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, NULL,
GetLastError(), err,
0, /* default language */ 0, /* default language */
(LPTSTR)msg, (LPTSTR)msg,
(DWORD)sizeof(msg), (DWORD)sizeof(msg),

View File

@ -28,6 +28,8 @@ extern "C" {
#endif #endif
void win32_throw_exception(JNIEnv *env, char *msg); void win32_throw_exception(JNIEnv *env, char *msg);
void win32_throw_error(JNIEnv *env, LONG err);
void win32_throw_last_error(JNIEnv *env); void win32_throw_last_error(JNIEnv *env);
#ifdef __cplusplus #ifdef __cplusplus
} }