move GetLastError and GetErrorMessage to base class

This commit is contained in:
Doug MacEachern committed 2005-06-26 00:50:08 +00:00
1 parent 67494670b6
commit 5cd9bfd25e
4 files changed
+28 -27

No files matched your search

-23
View File
@@ -262,29 +262,6 @@ JNIEXPORT jboolean SIGAR_JNI(win32_Service_DeleteService)
return DeleteService((SC_HANDLE)handle);
}
JNIEXPORT jstring SIGAR_JNI(win32_Service_GetErrorMessage)
(JNIEnv *env, jclass, jint error)
{
LPTSTR lpMsg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
FORMAT_MESSAGE_IGNORE_INSERTS|
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(LPTSTR)&lpMsg, 0, NULL);
return env->NewString((const jchar *)lpMsg, lstrlen(lpMsg));
}
/**
* XXX: this should probablly be moved into a util class
*/
JNIEXPORT jint SIGAR_JNI(win32_Service_GetLastError)
(JNIEnv *, jclass)
{
return GetLastError();
}
JNIEXPORT jlong SIGAR_JNI(win32_Service_OpenSCManager)
(JNIEnv *env, jclass, jstring machine, jint access)
{
+23
View File
@@ -1,4 +1,7 @@
#ifdef WIN32
#define UNICODE
#define _UNICODE
#include <pdh.h>
#include <pdhmsg.h>
@@ -19,6 +22,26 @@ void win32_throw_exception(JNIEnv *env, char *msg)
JENV->ThrowNew(env, exceptionClass, msg);
}
JNIEXPORT jint SIGAR_JNI(win32_Win32_GetLastError)
(JNIEnv *env, jclass cls)
{
return GetLastError();
}
JNIEXPORT jstring SIGAR_JNI(win32_Win32_GetErrorMessage)
(JNIEnv *env, jclass cls, jint error)
{
LPTSTR msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
FORMAT_MESSAGE_IGNORE_INSERTS|
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(LPTSTR)&msg, 0, NULL);
return JENV->NewString(env, (const jchar *)msg, lstrlen(msg));
}
#ifdef __cplusplus
}
#endif
@@ -330,10 +330,6 @@ public class Service extends Win32 {
private static native boolean DeleteService(long handle);
private static native String GetErrorMessage(int error);
private static native int GetLastError();
private static native long OpenSCManager(String machine,
int access);
@@ -12,4 +12,9 @@ abstract class Win32 {
}
}
static native String GetErrorMessage(int error);
static native int GetLastError();
}