Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Blocking keys in NT AND Win95/98

Posted on 1998-10-08
1
Medium Priority
?
191 Views
Last Modified: 2010-04-02
I want to block keys in my login-app...
When this app is executed, I want to block keys like CTRL+ALT+DEL and CTRL+TAB, etc, etc, everything that can switch task or kill my app.
This app is going to be executed at startup.
0
Comment
Question by:ajosefsson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 300 total points
ID: 1174712
Well, the only way to totally 'control' any keyboard related events is to use a system wide message hook (see 'SetWindowsHookEx()' and 'WH_GETMESSAGE', the hook has to reside in a DLL), e.g.:

LRESULT CALLBACK HookProc   (   int     nCode,  // hook code
                                WPARAM  wParam, // removal flag
                                LPARAM  lParam  // address of structure with message
                            )
{
    PMSG    pmsg    =   ( PMSG) lParam;
    MSG     msg;

    if  (   0   >   nCode   ||  PM_NOREMOVE ==  wParam)
        {
            return  (   CallNextHookEx  (   g_hhk,
                                            nCode,
                                            wParam,
                                            lParam
                                        )
                    );
        }

    if  (   /* ... check whether it's a mouse message */
            PeekMessage (   &msg,
                            pmsg->hwnd,
                            WM_KEYFIRST,
                            WM_KEYLAST,
                            PM_NOREMOVE
                        )
        )
        {
      /* this one is for us, so check key state */
       if (       0x80000000 & GetKeyState(VK_LMENU)
           && 0x80000000 & GetKeyState(VK_CONTROL)
            )
            {
           
            /* appropriate action, e.g. suppress msg by removing it /*
            PeekMessage (   &msg,
                            pmsg->hwnd,
                            WM_MOUSEFIRST,
                            WM_MOUSELAST,
                            PM_REMOVE
                        );
           }
        }

 
}

On NT, you'll have to interact with MSGINA if your application is expected to run before a user logs on.

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question