flat assembler
Message board for the users of flat assembler.
Index
> Windows > Keyboard layuot |
Author |
|
LocoDelAssembly 28 Sep 2012, 13:48
Take a look at this:
Code: format PE GUI 4.0 entry start include 'win32w.inc' ; Using Unicode version so LCIDToLocaleName can be used section '.code' code readable executable fmt du "Primary Language ID = %d", 13, 10,\ "SubLanguage ID = %d", 13, 10,\ "Language name = ""%s""", 0 start: invoke GetModuleHandle, 0 invoke GetWindowThreadProcessId, eax, 0 invoke GetKeyboardLayout, eax movzx eax, ax mov ecx, eax mov edx, eax shr edx, 10 and eax, (1 shl 10) - 1 mov [priLang], eax mov [subLang], edx invoke LCIDToLocaleName, ecx, langName, 256, 0 cinvoke wsprintf, LayOut, fmt, [priLang], [subLang], langName ; I wanna display the result here! But the MessageBox displays nothing!!! invoke MessageBox, 0, LayOut, 0, 0 exit: invoke ExitProcess, 0 section '.data' data readable writable LayOut rw 256 ; Placed here, in a section with writable permission set priLang dd ? subLang dd ? langName rw 256 data import library kernel32, 'KERNEL32.DLL',\ user32, 'USER32.DLL' import kernel32,\ ExitProcess, 'ExitProcess',\ GetModuleHandle, 'GetModuleHandleW',\ LCIDToLocaleName, 'LCIDToLocaleName' include 'api\user32.inc' end data |
|||
28 Sep 2012, 13:48 |
|
KostX 28 Sep 2012, 14:26
Thank you, LocoDelAssembly. I thinking that is!
But I have a new problam. Whan I executing my application i've an error: Entry point into procedure "LCIDToLocaleName" not found. This is due to the fact that I live in Ukraine and I have a different version of the Shell32.dll??? We're using ANSI coding. Last edited by KostX on 28 Sep 2012, 14:27; edited 1 time in total |
|||
28 Sep 2012, 14:26 |
|
revolution 28 Sep 2012, 14:27
LCIDToLocaleName was introduced in Vista and Server2008. It you are using XP or below then it won't be available.
|
|||
28 Sep 2012, 14:27 |
|
KostX 28 Sep 2012, 14:31
Thank you, revolution. I've found. I check my programm in computer with Win8, than it works. I've copied kernel32.dll of Win 8 on my computer.
Now I'm experimenting =) |
|||
28 Sep 2012, 14:31 |
|
KostX 28 Sep 2012, 16:37
Excuse me, have you a variant for Windows XP?
|
|||
28 Sep 2012, 16:37 |
|
LocoDelAssembly 28 Sep 2012, 22:01
Sorry, didn't notice that function also needed Vista and later. This code does something different, but seems everything it uses is available in XP:
Code: LOCALE_SLANGUAGE = 2 format PE GUI 4.0 entry start include 'win32a.inc' section '.code' code readable executable fmt db "Primary Language ID = %d", 13, 10,\ "SubLanguage ID = %d", 13, 10,\ "Language = ""%s""", 0 start: invoke GetModuleHandle, 0 invoke GetWindowThreadProcessId, eax, 0 invoke GetKeyboardLayout, eax movzx eax, ax mov ecx, eax mov edx, eax shr edx, 10 and eax, (1 shl 10) - 1 mov [priLang], eax mov [subLang], edx invoke GetLocaleInfo, ecx, LOCALE_SLANGUAGE, languageName, 128 cinvoke wsprintf, message, fmt, [priLang], [subLang], languageName invoke MessageBox, 0, message, 0, 0 exit: invoke ExitProcess, 0 section '.data' data readable writable message rb 256 ; Placed here, in a section with writable permission set languageName rb 128 priLang dd ? subLang dd ? data import library kernel32, 'KERNEL32.DLL',\ user32, 'USER32.DLL' include 'api\kernel32.inc' include 'api\user32.inc' end data Code: --------------------------- Error --------------------------- Primary Language ID = 10 SubLanguage ID = 11 Language = "Spanish (Argentina)" --------------------------- OK --------------------------- |
|||
28 Sep 2012, 22:01 |
|
KostX 29 Sep 2012, 08:45
Thank you, LocoDelAssembly. It works!
|
|||
29 Sep 2012, 08:45 |
|
hopcode 29 Sep 2012, 16:47
gymkhana among deprecations and mess,
because LOCALE_SLANGUAGE deprecated for win7 while GetLocalInfo deprecated from Vista. ok LocoDelAssembly wrote: ...Anyone knows an easier method to get the layout name? Code: ;--- first get all available HKLs GetKeyboardLayoutList,2,hkl_list ;--- i have 0407h and 0409h ;--- then, knowing what your app can manage,0407h and 0409h in my case, ;--- activate the HKL you need for the current process (100h) mov eax,dword[hkl_list+4] ActivateKeyboardLayout,eax,100h ;--- now getting the layout for the current process, it rets 0409h ;--- hkl for English USA xor eax,eax GetKeyboardLayout, eax ;--- having it, feed it with LOCALE_SLANGUAGE = 2 for a check and eax,0FFFFh GetLocaleInfo, eax, 2, langname, 128 ;--- langname now point to "English (USA)" in this way it should return the right string "Latin American" Cheers, _________________ ⠓⠕⠏⠉⠕⠙⠑ |
|||
29 Sep 2012, 16:47 |
|
hopcode 29 Sep 2012, 17:26
but this works too on Vista,
i set EN 0409h below on the taskbar near the current date, then i start application Code: xor eax,eax invoke ActivateKeyboardLayout,eax,100h ;-- it return 0407h (German) xor eax,eax invoke GetKeyboardLayout, eax ;---it returns 0409h (English USA) confirmed on Xp ? _________________ ⠓⠕⠏⠉⠕⠙⠑ |
|||
29 Sep 2012, 17:26 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.