• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            woaidongmao

            文章均收錄自他人博客,但不喜標題前加-[轉貼],因其丑陋,見諒!~
            隨筆 - 1469, 文章 - 0, 評論 - 661, 引用 - 0
            數據加載中……

            清除無效的托盤圖標

            int CDeleteTrayNullIconDlg::DeleteTrayNullIcon(BOOL &bNullBeDel)
            {
                HWND  hNotify1;
                int iMethod=0;
                bNullBeDel = FALSE;
                HWND  hStatus=::FindWindow("Shell_TrayWnd",NULL);  //
            得到任務欄句柄
                if  (hStatus==NULL) 
                { 
                    //AfxMessageBox ( "Get Shell_TrayWnd error!" );
                    return -1; 
                } 
                HWND  hNotify=FindWindowEx(hStatus,NULL,"TrayNotifyWnd",NULL); //
            右下角區域
                if  (hNotify==NULL)
                { 
                    //AfxMessageBox ( "Get TrayNotifyWnd error!" );
                    return -1; 
                }
            goto1:
                if (iMethod<1)
                {
                    hNotify1=FindWindowEx(hNotify,NULL,"SysPager",NULL);
                    if  (hNotify==NULL) 
                    { 
                        //AfxMessageBox ( "Get SysPager error!" );
                        return -1; 
                    }
                    if (hNotify1==NULL)
                    {
                        hNotify1=hNotify;
                    }
                }
                else
                {
                    hNotify1=hNotify;
                }

                HWND  hNotify1_0=FindWindowEx(hNotify1,NULL,"ToolBarWindow32",NULL);//右下角區域(不包括時間)
                if  (hNotify1_0==NULL)  
                { 
                    //AfxMessageBox ( "Get ToolBarWindow32 error!" );
                    return -1; 
                } 
                //-------------------
            以上是得到任務欄右下腳一塊地方的句柄
                DWORD  pid = 0; 
                GetWindowThreadProcessId(hNotify1_0,&pid); 
                if  (pid==NULL) 
                { 
                    //AfxMessageBox ( "Get pid error!" );
                    return -1; 
                }  
               
                HANDLE  hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_ALL_ACCESS,true,pid); 
                if  (hProcess==NULL) 
                { 
                    //AfxMessageBox ( "Get hd error!" );
                    return -1; 
                } 
                ::SendMessage(hNotify1_0,WM_PAINT ,NULL,NULL);
                CRect rect;
                ::GetWindowRect(hNotify1_0,&rect);
                ::InvalidateRect(hNotify1_0,&rect,FALSE);

                int  iNum=::SendMessage(hNotify1_0,TB_BUTTONCOUNT ,NULL,NULL);  //獲取任務欄上圖標個數
                if (iNum<1 && iMethod==0)
                {
                    iMethod=2;
                    goto goto1;
                }

                unsigned long n = 0; 
                TBBUTTON  *pButton = new TBBUTTON; 
                CString  strInfo = _T(""); 
                wchar_t  name[256] = {0}; 
                TBBUTTON  BButton;
                unsigned   long    whd,proid;
                CString x;
               
                for(int i=0; i<iNum; i++) 
                { 
                    ::SendMessage(hNotify1_0,TB_GETBUTTON,i,(LPARAM)(&BButton)); 
                    ReadProcessMemory(hProcess,&BButton,pButton,sizeof(TBBUTTON),&n);  
                    if  (pButton->iString != 0xffffffff) 
                    { 
                        try 
                        { 
                            ReadProcessMemory(hProcess,(void *)pButton->iString,name,255,&n);
                        }
                        catch(...) 
                        { 
                        }     
                        strInfo.Format("%d : %s ",i+1,CString(name));
                        TRACE(strInfo);
                    }
                   
                    try
                    {  
                        whd=0;  
                        ReadProcessMemory(hProcess,(void *)pButton->dwData,&whd,4,&n);  
                    }  
                    catch(...)
                    {  
                    }  
                    proid=NULL;
                    GetWindowThreadProcessId((HWND)whd,&proid);  
                    if(proid==NULL)
                    {
                        bNullBeDel = TRUE;
                        ::SendMessage(hNotify1_0,TB_DELETEBUTTON,i,0);
                    }
                }
                delete pButton;

                return 0;
            }

            原作者謝紅偉,上代碼我作了幾個地方修改與優化

            #define  WM_NOTIFYICON WM_USER+5

            void CDeleteTrayNullIconDlg::OnButton1()
            {
            BOOL bNullBeDel = FALSE;
            do
            {
              DeleteTrayNullIcon ( bNullBeDel );
            } while ( bNullBeDel );

            NOTIFYICONDATA ni;
            ni.cbSize=sizeof(ni);
            ni.hIcon=m_hIcon;
            //ni.hWnd=m_pMainWnd->m_hWnd;
            //strcpy(nd.szTip, "
            我的托盤");
            ni.uCallbackMessage=WM_NOTIFYICON;
            ni.uFlags= NIF_ICON | NIF_MESSAGE | NIF_TIP ;
            ni.uID=IDR_MAINFRAME;

            Shell_NotifyIcon(NIM_ADD, &ni);
            Shell_NotifyIcon(NIM_DELETE, &ni);
            AfxMessageBox ( "
            清除無效的托盤圖標已經完成", MB_ICONINFORMATION );

            }

            posted on 2011-08-27 15:15 肥仔 閱讀(1210) 評論(0)  編輯 收藏 引用 所屬分類: Windows開發

            国内精品伊人久久久久av一坑| 天天综合久久久网| 香蕉aa三级久久毛片| 奇米影视7777久久精品| 久久精品国产半推半就| 日韩美女18网站久久精品 | 狠狠88综合久久久久综合网| …久久精品99久久香蕉国产| 国内精品久久久久久久coent | 国产精品久久久久乳精品爆 | 国产福利电影一区二区三区久久老子无码午夜伦不 | 一级女性全黄久久生活片免费 | 国产一区二区三区久久| 四虎久久影院| 国内精品久久久久久久coent| 狠狠色丁香久久婷婷综合| 久久se精品一区二区影院 | 久久人搡人人玩人妻精品首页| 久久久精品人妻一区二区三区蜜桃 | 久久精品国产91久久综合麻豆自制| 精品久久人人做人人爽综合| 久久婷婷五月综合色奶水99啪 | 久久久久久久综合狠狠综合| 日本福利片国产午夜久久| 亚洲AV日韩精品久久久久| 久久久久九九精品影院| 亚洲国产精品一区二区久久| 久久亚洲AV成人出白浆无码国产| 国产精品久久久久久久app| 国产精品欧美久久久久天天影视| 国产V亚洲V天堂无码久久久| 国产A级毛片久久久精品毛片| 亚洲?V乱码久久精品蜜桃| 久久五月精品中文字幕| 精品国产乱码久久久久久浪潮| 国产 亚洲 欧美 另类 久久| 国产精品熟女福利久久AV| 国産精品久久久久久久| 久久性生大片免费观看性| 合区精品久久久中文字幕一区| 久久亚洲国产精品成人AV秋霞|