一个用IE控件浏览文档的程序,我需要禁止用户通过IE控件进入资源管理器,就需要屏蔽鼠标右键.现在对于用鼠标右键产生的消息已经屏蔽了,由于键盘上的菜单键也有这个功能,请问是否可以通过注册表进行屏蔽,让该键无效.如果不行还有其他什么方法吗?操作系统采用WIN2K.因为曾经有一篇文章报道说有恶意网站屏蔽了作者的鼠标右键和键盘菜单键.情况很紧急,请给予帮助,谢谢.

解决方案 »

  1.   

    用键盘钩子,下面是我在自己工程里的一段函数,根据你的应用把它改一下就可以了,具体可以看msdn。LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
    BOOL fEatKeystroke = TRUE ;
    BOOL ppFlag ; if ( retestflag == 0 )
    {
    EnableMenuItem (hMenu, IDM_APP_RETEST, MF_ENABLED) ;  
    retestflag ++;
    }
    if ( nCode == HC_ACTION )
    {
    switch (wParam)
    {
    case WM_KEYDOWN:
    case WM_SYSKEYDOWN:


     pp = (PKBDLLHOOKSTRUCT)lParam ;
     if ( pp->scanCode == current->scanCode )
     {
     ppFlag = TRUE ;  if ( pp->scanCode == 0x1D )         // Discriminate left Ctrl and right Ctrl
     {
    if( (pp->flags & LLKHF_EXTENDED) == 0 && lCtr.status == Active && rCtr.status == Ready 
    ||  (pp->flags & LLKHF_EXTENDED) == 1 && lCtr.status == Hide && rCtr.status == Active )
    {
    ppFlag = TRUE ;
    }
    else ppFlag = FALSE ;
     }  if ( pp->scanCode == 0x38 )         // Discriminate left Alt and right Alt
     {
    if( (pp->flags & LLKHF_EXTENDED) == 0 && lAlt.status == Active && rAlt.status == Ready 
    ||  (pp->flags & LLKHF_EXTENDED) == 1 && lAlt.status == Hide && rAlt.status == Active )
    {
    ppFlag = TRUE ;
    }
    else ppFlag = FALSE ;
     }  if ( pp->scanCode == 0x52 )         // Discriminate Ins  and Fn+M
     {
    if( (pp->flags & LLKHF_EXTENDED) == 1 && Ins.status == Active && Fn.status == Ready 
    ||  (pp->flags & LLKHF_EXTENDED) == 0 && Ins.status == Hide && Fn.status == Active )
    {
    ppFlag = TRUE ;
    }
    else ppFlag = FALSE ;
     }  if ( pp->scanCode == 0x4D )         // Display Fn+M
     {
    hdc = GetDC (hwnd) ;

    MM.status = Active ;
    ShowKey (hwnd,  MM.xLeft, MM.yTop, MM.xRight,
         MM.yBottom, MM.status, MM.name) ; ReleaseDC (hwnd, hdc) ;

     }  if( ppFlag == TRUE )
     {
     hdc = GetDC (hwnd) ;  current -> status = Hide ;
     ShowKey (hwnd,  current->xLeft, current->yTop, current->xRight,
         current->yBottom, current->status, current->name) ;      current = current->next ;
         current -> status = Active ;  ShowKey (hwnd,  current->xLeft, current->yTop, current->xRight,
         current->yBottom, current->status, current->name) ;
     
                 ReleaseDC (hwnd, hdc) ;
     
     }
     }
     if ( current->next == NULL )
     {
     result = 0;                        // if all pass , return 0
     PaintTheBlock(hwnd, result );
     Sleep(1000);
     QUIT();
     }
     break;     case WM_KEYUP:
         case WM_CHAR:
         case WM_DEADCHAR:
         case WM_SYSKEYUP:
         case WM_SYSCHAR:
         case WM_SYSDEADCHAR:   break ; }
    } return(fEatKeystroke ? 1 : CallNextHookEx(NULL,nCode,wParam,lParam));
    }