M
Mat
Hi
I have tried for two days to take the control of the 4 hardware keys
of my Ipaq. I need to handle them in my java application. For that I
use JNI and a dll written in c++ (with Visual Embedded c++). The Dll -
Java communication works very well, that is not my problem.
My problem appears in the c++ dll. To catch the hard keys I use the
RegisterHotKey function as it is described in
http://www.pocketpcdn.com/articles/handle_hardware_keys.html . The
code is listed below :
-------------------------------------------------------------------------------
#include "stdafx.h"
#include "jni.h"
#include "EcouteTouchesPDA.h"
#include <stdio.h>
#define VK_MYAPP1 193 // Calendar
#define VK_MYAPP2 194 // Contacts
#define VK_MYAPP3 195 // Inbox
#define VK_MYAPP4 196 // iTask
#define VK_MYAPP5 197 // Notes
typedef BOOL (__stdcall *UnregisterFunc1Proc)( UINT, UINT );
//Fonction appelée par l'appli JAVA
JNIEXPORT void JNICALL
Java__EcouteTouchesPDA_intercepteLesTouches(JNIEnv *env, jobject obj)
{
HINSTANCE hCoreDll;
UnregisterFunc1Proc procUndergisterFunc;
hCoreDll = LoadLibrary(_T("coredll.dll"));
ASSERT(hCoreDll);
procUndergisterFunc = (UnregisterFunc1Proc)GetProcAddress(hCoreDll,
_T("UnregisterFunc1"));
ASSERT(procUndergisterFunc);
for (int i = 0xc1; i<=0xcf; i++)
{
BOOL bTest = procUndergisterFunc(MOD_WIN,0xc1);
// bTest IS TRUE !
bTest = RegisterHotKey(NULL,0xc1,MOD_WIN,0xc1);
// bTest IS FALSE !
}
MSG msg;
while(GetMessage(&msg,NULL,WM_HOTKEY,WM_HOTKEY))
{
Blablalbla ....
}
FreeLibrary(hCoreDll);
return;
}
--------------------------------------------------------------------------
As you can see, RegisterHotKey fails. A call to GetLastErrorCode()
just after RegisterHotKey() return "87", that matches
"ERROR_BAD_PARAMETER" I think...
Please help me I don't have more ideas to solve this problem (I'm a
c++ beginner). Notice that I DON'T USE MFC A DON'T WANT TO USE IT,
that's why the first paramater of RegisterHotKey is NULL.
Matthieu
I have tried for two days to take the control of the 4 hardware keys
of my Ipaq. I need to handle them in my java application. For that I
use JNI and a dll written in c++ (with Visual Embedded c++). The Dll -
Java communication works very well, that is not my problem.
My problem appears in the c++ dll. To catch the hard keys I use the
RegisterHotKey function as it is described in
http://www.pocketpcdn.com/articles/handle_hardware_keys.html . The
code is listed below :
-------------------------------------------------------------------------------
#include "stdafx.h"
#include "jni.h"
#include "EcouteTouchesPDA.h"
#include <stdio.h>
#define VK_MYAPP1 193 // Calendar
#define VK_MYAPP2 194 // Contacts
#define VK_MYAPP3 195 // Inbox
#define VK_MYAPP4 196 // iTask
#define VK_MYAPP5 197 // Notes
typedef BOOL (__stdcall *UnregisterFunc1Proc)( UINT, UINT );
//Fonction appelée par l'appli JAVA
JNIEXPORT void JNICALL
Java__EcouteTouchesPDA_intercepteLesTouches(JNIEnv *env, jobject obj)
{
HINSTANCE hCoreDll;
UnregisterFunc1Proc procUndergisterFunc;
hCoreDll = LoadLibrary(_T("coredll.dll"));
ASSERT(hCoreDll);
procUndergisterFunc = (UnregisterFunc1Proc)GetProcAddress(hCoreDll,
_T("UnregisterFunc1"));
ASSERT(procUndergisterFunc);
for (int i = 0xc1; i<=0xcf; i++)
{
BOOL bTest = procUndergisterFunc(MOD_WIN,0xc1);
// bTest IS TRUE !
bTest = RegisterHotKey(NULL,0xc1,MOD_WIN,0xc1);
// bTest IS FALSE !
}
MSG msg;
while(GetMessage(&msg,NULL,WM_HOTKEY,WM_HOTKEY))
{
Blablalbla ....
}
FreeLibrary(hCoreDll);
return;
}
--------------------------------------------------------------------------
As you can see, RegisterHotKey fails. A call to GetLastErrorCode()
just after RegisterHotKey() return "87", that matches
"ERROR_BAD_PARAMETER" I think...
Please help me I don't have more ideas to solve this problem (I'm a
c++ beginner). Notice that I DON'T USE MFC A DON'T WANT TO USE IT,
that's why the first paramater of RegisterHotKey is NULL.
Matthieu