Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* libdxlsw - dx console Language Switcher library
- * Copyright (C) 2012 Dmitry Hrabrov a.k.a. DeXPeriX
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
- #include <windows.h>
- #define MAX_LAYS 10
- __declspec(dllexport)
- int dxGetLayout(long a){
- unsigned int x;
- HWND hwnd;
- DWORD threadId;
- HKL currentLayout;
- hwnd = GetForegroundWindow();
- if( hwnd ){
- threadId = GetWindowThreadProcessId(hwnd, NULL);
- currentLayout = GetKeyboardLayout(threadId);
- x = (unsigned int)currentLayout & 0x0000FFFF;
- return x;
- } else return -1;
- }
- __declspec(dllexport)
- int dxSetLayout(long toLocale){
- unsigned int i, n, Lid;
- HKL lpList[MAX_LAYS];
- HKL currentLayout;
- HWND hwnd;
- n = GetKeyboardLayoutList(0, NULL);
- n = GetKeyboardLayoutList(n, lpList);
- for(i=0; i<n; i++){
- Lid = ((unsigned int)lpList[i]) & 0x0000FFFF; /* bottom 16 bit */
- if( Lid == toLocale ){
- currentLayout = lpList[i];
- hwnd = GetForegroundWindow();
- if( hwnd ){
- PostMessage(hwnd,WM_INPUTLANGCHANGEREQUEST,0,(LPARAM)(currentLayout));
- return Lid;
- }
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment