Serious RegisterHotKey() problem !

From: Mat (matthieu_cham_at_hotmail.com)
Date: 01/14/04


Date: 14 Jan 2004 10:35:46 -0800

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



Relevant Pages

  • Serious RegisterHotKey() problem !
    ... I have tried for two days to take the control of the 4 hardware keys ... use JNI and a dll written in c++. ... Java communication works very well, ... As you can see, RegisterHotKey fails. ...
    (comp.lang.cpp)
  • Serious RegisterHotKey() problem !
    ... I have tried for two days to take the control of the 4 hardware keys ... use JNI and a dll written in c++. ... Java communication works very well, ... As you can see, RegisterHotKey fails. ...
    (comp.lang.java.developer)
  • Re: Java programmer lured back by .Net (Questions)
    ... in .NET a form is simply a class so yes it could easily be placed into a DLL and then use Ngen to make a native image of it. ... Of course it learned a lot from Java, and improved upon many things which Java is slowly catching up on. ... As far as code security you're in the same boat as Java since it compiles down to MSIL instead of bytecode of which both can reverse engineered very easily. ... I would like to be able to place my executable on my remote server and then "load" the executables on demand from accross the internet - so that there are no executables on the local machine for prying eyes to reverse engineer. ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: Java programmer lured back by .Net (Questions)
    ... in .NET a form is simply a class so yes it could easily be placed into a DLL and then use Ngen to make a native image of it. ... Of course it learned a lot from Java, and improved upon many things which Java is slowly catching up on. ... As far as code security you're in the same boat as Java since it compiles down to MSIL instead of bytecode of which both can reverse engineered very easily. ... My backend is pure Java running on Unix - but because SWING is so ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: JNI EXCEPTION_ACCESS_VIOLATION
    ... I am not experienced in coding a dll and access it via ... Java, but, I would say to you that, if you do not mind, try to use the ... The code will crash when running under XP Service Pack 2 ... The code will NOT crash when running under Windows 2000 Service Pack 4 ...
    (comp.lang.java.programmer)