0

I have

DWORD dwThreadID = GetCurrentThreadId();
HKL hCurKeyboard = GetKeyboardLayout(dwThreadID);

that return HKL current keyboard i need compare it with some char

char defaultLanguage[64]="0x04090409";

How can i compare HKL hCurKeyboard with defaultLanguage

or How can i create some HKL with this value "0x04090409"

        char defaultLanguageLayout[64] = "0x04090409";
        DWORD dwThreadID = GetCurrentThreadId();
        HKL hCurKeyboard = GetKeyboardLayout(dwThreadID);
//->>       if(hCurKeyboard!=defaultLanguageLayout) 
        {

            UINT i;
            HKL hklCurrent;
            UINT uLayouts;
            HKL * lpList;

            uLayouts = GetKeyboardLayoutList(0, NULL);
            lpList = (HKL*) malloc(uLayouts * sizeof(HKL));
            uLayouts = GetKeyboardLayoutList(uLayouts, lpList);

            for(i=0; i<uLayouts; i++)
            {
                hklCurrent = *(lpList + i);

//->>               if(hklCurrent == defaultLanguageLayout){
                    ActivateKeyboardLayout(hklCurrent, 0);
                }
            }

Thanks in advance.

Oleksandr Fentsyk
  • 5,256
  • 5
  • 34
  • 41

1 Answers1

1

According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms646305(v=vs.85).aspx, the best thing to do is something like:

    HKL defaultLanguageLayout = LoadKeyboardLayout("0x04090409", KLF_SUBSTITUTE_OK);
    DWORD dwThreadID = GetCurrentThreadId();
    HKL hCurKeyboard = GetKeyboardLayout(dwThreadID);
    if(hCurKeyboard!=defaultLanguageLayout) {

But I don't understand Keyboard layouts enough to know if the second parameter is correct.

Mooing Duck
  • 64,318
  • 19
  • 100
  • 158
  • 1
    @Sasha: [Cicida says you can just cast it](http://chat.stackoverflow.com/transcript/message/4048672#4048672), try that? – Mooing Duck Jun 08 '12 at 17:19