Ok I just ripped this straight from some of my code .. it should help get you going. Preventing users from switching is sort of frown upon, however there are times when it is needed and the programmer should use at their own discretion. In my case this is from a child's game (my 2 year old) and I absolutely didn't want him exiting out, however there was a convient way to exit that couldn't be done accidently built in.
Code:
//set keyboardhook
hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0 );
...
// keyboard hook proc
LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam )
{
if (nCode < 0 || nCode != HC_ACTION ) return CallNextHookEx( hKeyboardHook, nCode, wParam, lParam);
KBDLLHOOKSTRUCT* p = (KBDLLHOOKSTRUCT*)lParam;
if(p->vkCode==VK_TAB && p->flags & LLKHF_ALTDOWN) return 1; //disable alt-tab
if((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) return 1;//disable windows keys
if (p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN) return 1;//disable alt-escape
BOOL bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);//checks ctrl key pressed
if (p->vkCode == VK_ESCAPE && bControlKeyDown) return 1; //disable ctrl-escape
return CallNextHookEx( hKeyboardHook, nCode, wParam, lParam );
}
...
// cleanup
UnhookWindowsHookEx( hKeyboardHook );
You return 1 (TRUE) from the keyboardhook proc for any key press/combination you want disabled or CallNestHookEx() for the ones you want to allow