zoukankan      html  css  js  c++  java
  • (C#)Windows Shell 外壳编程系列9 QueryInfo 扩展提示

    (本系列文章由柠檬的(lc_mtt)原创,转载请注明出处,谢谢~)

    QueryInfo扩展
    活动桌面引入一项新特性,当你在某些特定对象上旋停鼠标时,工具提示将显示它们的描述。我们可以使用 QueryInfo 扩展为Shell中的其它对象提供自定义的工具提示。如下图:

    事实上,这个功能实现比前两个 Shell 扩展更简单,它仅仅是实现 IQueryInfo 接口:

    IQueryInfo 接口定义
    [ComImport(), ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), GuidAttribute("00021500-0000-0000-c000-000000000046")]
    public interface IQueryInfo
    {
        [PreserveSig]
    uint GetInfoTip(uint dwFlags, out IntPtr pszInfoTip);
        [PreserveSig]
    uint GetInfoFlags(out uint dwFlags);
    }

    IQueryInfo 接口只包含两个函数,其中 GetInfoFlags 目前还不被支持并且必须返回 0。

    GetInfoTip() 让我们返回工具提示文本 字符串。其参数:

    dwFlags 当前并不被使用。

    pszInfoTip 是个Unicode 字符串指针变量的指针,我们要将其赋值为我们所分配的字符串缓冲区的指针。

    还记得之前使用 IPersistFile 接口获取单个文件路径保存在 szFileName 变量中吗?现在也可以使用:

    GetInfoTip
    public uint GetInfoTip(uint dwFlags, out IntPtr pszInfoTip)
    {
        StreamReader sr = new StreamReader(szFileName, Encoding.GetEncoding("gb2312"));
    string text = sr.ReadToEnd();
        sr.Close();
    if (text.Length > 256)
        {
            text = text.Substring(0, 256) + "";
        }
    string tip = "------------- 内容预览 -------------\r\n\r\n" + text;
        pszInfoTip = Marshal.StringToCoTaskMemUni(tip);
    return S_OK;
    }

    代码:https://files.cnblogs.com/lemony/MyContextMenu.rar

    这一章似乎过于简单。下一章将简述如何使用 IShellPropSheetExt 接口为文件/文件夹增加属性页,如下:

  • 相关阅读:
    Document
    Document
    Document
    css3 无缝轮播效果小demo(轮播效果/渐隐渐现效果)
    4.Redux (这篇文章需要修改)
    3.React-router/BrowserRouter/withRouter/Switch/history/exact/strict/Link/Redirect/PropTypes
    2.React数据传递 之☞ 父子之间数据传递 / React生命周期
    1.React (基础篇)
    13. Vuex ,一个专为 Vue.js 应用程序开发的状态管理模式
    12. vue 路由(vue-router)
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/1764032.html
Copyright © 2011-2022 走看看