刷新无效托盘图标
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
只回答业务咨询
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
#include <AFX.H> #include <COMMCTRL.H> #include <iostream.h> int main() { HWND hStatus=::FindWindow("Shell_TrayWnd",NULL); //得到任务栏句柄 if (hStatus==NULL) { cout<<"Get Shell_TrayWnd error!\n"; return -1; } HWND hNotify=FindWindowEx(hStatus,NULL,"TrayNotifyWnd",NULL); //右下角区域 if (hNotify==NULL) { cout<<"Get TrayNotifyWnd error!\n"; return -1; } HWND hNotify1=FindWindowEx(hNotify,NULL,"SysPager",NULL); if (hNotify==NULL) { cout<<"Get SysPager error!\n"; return -1; } HWND hNotify1_0=FindWindowEx(hNotify1,NULL,"ToolBarWindow32",NULL);//右下角区域(不包括时间) if (hNotify1_0==NULL) { cout<<"Get ToolBarWindow32 error!\n"; return -1; } //-------------------以上是得到任务栏右下脚一块地方的句柄 DWORD pid = 0; GetWindowThreadProcessId(hNotify1_0,&pid); if (pid==NULL) { cout<<"Get pid error!\n"; return -1; } HANDLE hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_ALL_ACCESS,true,pid); if (hProcess==NULL) { cout<<"Get hd error!\n"; 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); //获取任务栏上图标个数 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\n",i+1,CString(name)); TRACE(strInfo); cout<<strInfo<<endl; } try { whd=0; ReadProcessMemory(hProcess,(void *)pButton->dwData,&whd,4,&n); } catch(...) { } proid=NULL; GetWindowThreadProcessId((HWND)whd,&proid); if(proid==NULL) ::SendMessage(hNotify1_0,TB_DELETEBUTTON,i,0); } delete pButton; return 0; } |
学习日记,兼职软件设计,软件修改,毕业设计。
本文出自 学习日记,转载时请注明出处及相应链接。
本文永久链接: https://www.softwareace.cn/?p=1381