I'm trying to write a program in Java which detects how long a computer has been idle. This can't be accomplished in pure Java so I have to interface with some C/C++ code. I found a suitable Windows DLL at http://www.codeproject.com/dll/trackuseridle.asp.
The header for the DLL looks like this:
I've written the following C to try and use the functionality provided by the DLL from within Java:
__declspec(dllimport) BOOL IdleTrackerInit();
__declspec(dllimport) void IdleTrackerTerm();
__declspec(dllimport) DWORD IdleTrackerGetLastTickCount();
However, when I try to compile with GCC, I get the following errors:
#define MILLISECONDS 1000
JNIEXPORT jboolean JNICALL
Java_IdleTimer_init(JNIEnv *env, jobject obj)
JNIEXPORT void JNICALL
Java_IdleTimer_terminate(JNIEnv *env, jobject obj)
JNIEXPORT jint JNICALL
Java_IdleTimer_idleTime(JNIEnv *env, jobject obj)
return (jint)(GetTickCount() - IdleTrackerGetLastTickCount()) / MILLISECONDS;
c:\windows\TEMP/cc22zcgb.o(.text+0x7):idletime.c: undefined reference to `_imp__IdleTrackerInit'
c:\windows\TEMP/cc22zcgb.o(.text+0x1d):idletime.c: undefined reference to `_imp__IdleTrackerTerm'
c:\windows\TEMP/cc22zcgb.o(.text+0x36):idletime.c: undefined reference to `_imp__IdleTrackerGetLastTickCount'
I know my Java and a good deal of C but nothing as far as C++ or Windows/DLLs. I wasn't sure if trying to access a C++ DLL from C was my problem.
Can anyone point me in the right direction to solve the problem? Any help much appreciated.