Was ist hier falsch?
-
Hallo,
ich habe diesen code hier:#pragma data_seg("Shared") HINSTANCE m_hInstance = NULL; HWND hNotifyWnd = NULL; HHOOK hMouse = NULL; HHOOK hKeyboard = NULL; time_t tmLastEvent = 0l; LONG m_mouseLocX = -1; // x-location of mouse position LONG m_mouseLocY = -1; // y-location of mouse position BOOL m_bInstance[10] = {FALSE}; #pragma data_seg() // Hooking functions time_t GetLastEventTime() { return tmLastEvent; } JNIEXPORT jlong JNICALL Java_Win32Native_getLastEventTime(JNIEnv *env, jclass obj) { return (long)tmLastEvent; } void ResetLastEventTime() { time( &tmLastEvent ); } LRESULT CALLBACK MouseFunc(int nCode, WPARAM wParam, LPARAM lParam) { if(nCode == HC_ACTION) { MOUSEHOOKSTRUCT* pStruct = (MOUSEHOOKSTRUCT*)lParam; // If there is a mouse event but the mouse has not moved // then there was no real mouse event if (pStruct->pt.x != m_mouseLocX || pStruct->pt.y != m_mouseLocY) { m_mouseLocX = pStruct->pt.x; m_mouseLocY = pStruct->pt.y; ResetLastEventTime(); } } return( CallNextHookEx(hMouse, nCode, wParam, lParam)); } LRESULT CALLBACK KeyboardFunc(int nCode, WPARAM wParam, LPARAM lParam) { if(nCode == HC_ACTION) { ResetLastEventTime(); } return( CallNextHookEx(hKeyboard, nCode, wParam, lParam)); } JNIEXPORT jlong JNICALL Java_Win32Native_getCurrentTime(JNIEnv *env, jobject obj){ time_t tmNow = 0L; time( &tmNow ); return (jlong)tmNow; } JNIEXPORT jboolean JNICALL Java_Win32Native_installFilters(JNIEnv *env, jclass obj, jstring strTitle, jlong tmNow) { const char *str = env->GetStringUTFChars(strTitle,0); // get the hwnd HWND hwnd = ::FindWindow(NULL,str); if(!hwnd) return false; env->ReleaseStringUTFChars(strTitle,str); // Set vars hNotifyWnd = hwnd; tmLastEvent = (long)tmNow; if (!hMouse) hMouse = SetWindowsHookEx(WH_MOUSE,(HOOKPROC)MouseFunc, m_hInstance, NULL); if (!hKeyboard) hKeyboard = SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardFunc, m_hInstance, NULL); return (jboolean)((hMouse != NULL) && (hKeyboard != NULL)); } JNIEXPORT jboolean JNICALL Java_Win32Native_killFilters(JNIEnv *env, jclass obj) { BOOL bReturn = FALSE; if( hMouse ) UnhookWindowsHookEx(hMouse); if( hKeyboard ) UnhookWindowsHookEx(hKeyboard); hMouse = NULL; hKeyboard = NULL; if(!hMouse && !hKeyboard) bReturn = TRUE; return (jboolean)bReturn; }Mit den borland command line tools bekomme ich folgende fehler (link):
http://halfprice.habra.com/Mirza/Bugs/cpp.jpg
Was ist hier los?
Gruss,
Mirza
-
Du hast die Header vergessen, in denen die Definitionen von HINSTANCE, HWND,... (<windows.h>) und time_t (<time.h> bzw. <ctime>) stehen, deshalb geht der Compiler davon aus, daß du dort eine (int-)Variable mit dem jeweiligen Namen anlegen willst.
PS: Das nächste Mal solltest du die Fehlermeldungen besser in Textform einfügen
