微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

winapi – 如何Shell_NotifyIcon而不在通知区域中添加图标

MSDN关于 Notifications and the Notification Area的文档非常清楚,要求在通知区域中显示一个图标以显示通知

To display a notification,you must
have an icon in the notification
area
. In certain cases,such as
Microsoft Communicator or battery
level,that icon will already be
present. In many other cases,however,
you will add an icon to the
notification area only as long as is
needed to show the notification.

由于我不想在通知区域添加任何图标,我想到的可能是“重用”现有的一个最常见的桌面上的图标.一个好的候选者可能是系统时钟.

我的问题是:

>我如何查找/枚举
NOTIFYICONDATA结构
系统时钟(AKA“日期和时间
属性“恢复时”?
>有没有更好的方法
完成这个(没有添加
一个图标)?

Shell_NotifyIcon在引擎盖下使用IUserNotification.我玩了它并制作了一个 utility out of it.我听说一个视力受损的系统管理员使用它来使他的脚本屏幕阅读器兼容.它是命令行,它没有消息循环.

它是自我意识的,这意味着发送给它的通知将排队(您可以控制它).为此,我提供了一个IQueryContinue实现.该项目是C语言,是开源的,帮助自己.

以下是它的内容

HRESULT NotifyUser(const NOTIFU_ParaM& params,IQueryContinue *querycontinue,IUserNotificationCallback *notifcallback)
 {
    HRESULT result = E_FAIL;

    IUserNotification *un = 0;
    IUserNotification2 *deux = 0; //french pun : "un" above stands for UserNotification but it also means 1 in french. deux means 2.

    //First try with the Vista/Windows 7 interface
    //(unless /xp flag is specified
    if (!params.mForceXP)
       result = CoCreateInstance(CLSID_UserNotification,CLSCTX_ALL,IID_IUserNotification2,(void**)&deux);

    //Fall back to Windows XP
    if (!SUCCEEDED(result))
    {
       TRACE(eWARN,L"Using Windows XP interface IUserNotification\n");
       result = CoCreateInstance(CLSID_UserNotification,IID_IUserNotification,(void**)&un);
    }
    else
    {
       TRACE(eINFO,L"Using Vista interface IUserNotification2\n");
       un = (IUserNotification*)deux; //Rather ugly cast saves some code...
    }

    if (SUCCEEDED(result))
    {
       const std::basic_string<TCHAR> crlf_text(L"\\n");
       const std::basic_string<TCHAR> crlf(L"\n");
       std::basic_string<TCHAR> text(params.mText);
       size_t look = 0;
       size_t found;

       //Replace \n with actual CRLF pair
       while ((found = text.find(crlf_text,look)) != std::string::npos)
       {
          text.replace(found,crlf_text.size(),crlf);
          look = found+1;
       }

       result = un->SetIconInfo(params.mIcon,params.mTitle.c_str());
       result = un->SetBalloonInfo(params.mTitle.c_str(),text.c_str(),params.mType);

       //Looks like it controls what happends when the X button is
       //clicked on
       result = un->SetBalloonRetry(0,250,0);

       if (deux)
          result = deux->Show(querycontinue,notifcallback);
       else
          result = un->Show(querycontinue,250);

       un->Release();
    }

    return result;
 }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2280端口映射到公网,发现经常被暴力破解,自己写了个临时封禁ip功能的脚本,实现5分钟内同一个ip登录密码错误10次就封禁这个ip5分钟,并且进行邮件通知使用步骤openwrt为19.07.03版本,其他版本没有测试过安装bashmsmtpopkg
#!/bin/bashcommand1&command2&wait从Shell脚本并行运行多个程序–杨河老李(kviccn.github.io)
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/phpls-ls 2.编辑修改.bash_profile文件(没有.bash_profile文件的情况下回自动创建)sudovim~/.bash_profile在文件的最后输入以下信息,然后保存退出exportPATH="/Applications/MAMP/bin/php/php7.2.20/b
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如zh_CN之类的语言包,进行中文语言包装:apt-getinstalllanguage-pack-zh-hans3、安装好后我们可以进行临时修改:然后添加中文支持: locale-genzh_CN.UTF-8临时修改> export LC_ALL='zh_CN.utf8'> locale永久
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexadecimalbash2#[0~1]0[0~7]0x[0~f]or0X[0~f]perl0b[0~1]0[0~7]0x[0~f]tcl0b[0~1]0o[0~7]0x[0~f]bashdifferentbaserepresntationreference2.StringlengthLanguageStr
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全命令补全方法:yum-yinstallbash-completionsource/usr/share/bash-completion/bash_completionsource<(kubectlcompletionbash)echo"source<(kubectlcompletionbash)">>~/.bashrc 
参考这里启动jar包shell脚本修改过来的#!/bin/bash#默认应用名称defaultAppName='./gadmin'appName=''if[[$1&&$1!=0]]thenappName=$1elseappName=$defaultAppNamefiecho">>>>>>本次重启的应用:$appName<
#一个数字的行#!/bin/bashwhilereadlinedon=`echo$line|sed's/[^0-9]//g'|wc-L`if[$n-eq1]thenecho$linefidone<1.txt#日志切割归档#!/bin/bashcd/data/logslog=1.logmv_log(){[-f$1]&&mv$1$2
#文件增加内容#!/bin/bashn=0cat1.txt|whilereadlinedon=[$n+1]if[$n-eq5]thenecho$lineecho-e"#Thisisatestfile.\n#Testinsertlineintothisfile."elseecho$linefidone#备份/etc目录#
# su - oraclesu: /usr/bin/ksh: No such file or directory根据报错信息:显示无法找到文件 /usr/bin/ksh果然没有该文件,但是发现存在文件/bin/ksh,于是创建了一个软连接,可以规避问题,可以成功切换到用户下,但无法执行系统自带命令。$. .bash_profile-ksh: .: .b