<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Was ist hier falsch?]]></title><description><![CDATA[<p>Hallo,<br />
ich habe diesen code hier:</p>
<pre><code class="language-cpp">#pragma data_seg(&quot;Shared&quot;)
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( &amp;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-&gt;pt.x != m_mouseLocX || pStruct-&gt;pt.y != m_mouseLocY)
		{
			m_mouseLocX = pStruct-&gt;pt.x;
			m_mouseLocY = pStruct-&gt;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( &amp;tmNow );
	return (jlong)tmNow;
}

JNIEXPORT jboolean JNICALL Java_Win32Native_installFilters(JNIEnv *env, jclass obj, jstring strTitle, jlong tmNow) 
{ 
	const char *str = env-&gt;GetStringUTFChars(strTitle,0);
	// get the hwnd
	HWND hwnd = ::FindWindow(NULL,str);
	if(!hwnd) return false;

    env-&gt;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) &amp;&amp; (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 &amp;&amp; !hKeyboard) bReturn = TRUE;
	return (jboolean)bReturn;
}
</code></pre>
<p>Mit den borland command line tools bekomme ich folgende fehler (link):</p>
<p><a href="http://halfprice.habra.com/Mirza/Bugs/cpp.jpg" rel="nofollow">http://halfprice.habra.com/Mirza/Bugs/cpp.jpg</a></p>
<p>Was ist hier los?</p>
<p>Gruss,<br />
Mirza</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/189619/was-ist-hier-falsch</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 08:59:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/189619.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Aug 2007 07:51:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Was ist hier falsch? on Wed, 15 Aug 2007 07:51:42 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe diesen code hier:</p>
<pre><code class="language-cpp">#pragma data_seg(&quot;Shared&quot;)
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( &amp;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-&gt;pt.x != m_mouseLocX || pStruct-&gt;pt.y != m_mouseLocY)
		{
			m_mouseLocX = pStruct-&gt;pt.x;
			m_mouseLocY = pStruct-&gt;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( &amp;tmNow );
	return (jlong)tmNow;
}

JNIEXPORT jboolean JNICALL Java_Win32Native_installFilters(JNIEnv *env, jclass obj, jstring strTitle, jlong tmNow) 
{ 
	const char *str = env-&gt;GetStringUTFChars(strTitle,0);
	// get the hwnd
	HWND hwnd = ::FindWindow(NULL,str);
	if(!hwnd) return false;

    env-&gt;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) &amp;&amp; (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 &amp;&amp; !hKeyboard) bReturn = TRUE;
	return (jboolean)bReturn;
}
</code></pre>
<p>Mit den borland command line tools bekomme ich folgende fehler (link):</p>
<p><a href="http://halfprice.habra.com/Mirza/Bugs/cpp.jpg" rel="nofollow">http://halfprice.habra.com/Mirza/Bugs/cpp.jpg</a></p>
<p>Was ist hier los?</p>
<p>Gruss,<br />
Mirza</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1344759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1344759</guid><dc:creator><![CDATA[mirzahat]]></dc:creator><pubDate>Wed, 15 Aug 2007 07:51:42 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist hier falsch? on Wed, 15 Aug 2007 08:06:07 GMT]]></title><description><![CDATA[<p>Du hast die Header vergessen, in denen die Definitionen von HINSTANCE, HWND,... (&lt;windows.h&gt;) und time_t (&lt;time.h&gt; bzw. &lt;ctime&gt;) stehen, deshalb geht der Compiler davon aus, daß du dort eine (int-)Variable mit dem jeweiligen Namen anlegen willst.</p>
<p>PS: Das nächste Mal solltest du die Fehlermeldungen besser in Textform einfügen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1344765</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1344765</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 15 Aug 2007 08:06:07 GMT</pubDate></item></channel></rss>