(C #) Windows Shell programming Series 9-QueryInfo extension prompt

Source: Internet
Author: User

(This series of articles is original from lemon (lc_mtt). Please indicate the source for reprinting. Thank you ~)

 

Next to the previous section: (C #) Windows Shell programming Series 8-different icons with different extension names?

 

QueryInfo Extension
The Active Desktop introduces a new feature. When you hover your mouse over a specific object, the tooltip displays their descriptions. We can use QueryInfo extension to provide custom tooltip for other objects in Shell. For example:

In fact, this function is easier to implement than the first two Shell extensions. It only implements the IQueryInfo interface:

IQueryInfo Interface Definition
[ComImport (), ComVisible (true), InterfaceType (ComInterfaceType. InterfaceIsIUnknown), guidattriwn ("00021500-0000-0000-c000-000000000046")]
Public interface IQueryInfo
{
[PreserveSig]
Uint GetInfoTip (uint dwFlags, out IntPtr pszInfoTip );

[PreserveSig]
Uint GetInfoFlags (out uint dwFlags );
}

 

The IQueryInfo Interface contains only two functions. Currently, GetInfoFlags is not supported and 0 must be returned.

GetInfoTip () Let's return the tooltip text string. Its parameters:

DwFlags is not currently used.

PszInfoTip is a pointer to a Unicode string pointer variable. We want to assign it a pointer to the string buffer we have allocated.

 

Do you still remember to use the IPersistFile interface to retrieve a single file path and save it in the szFileName variable? You can also use:

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 = "------------- Content preview ------------- \ r \ n" + text;

PszInfoTip = Marshal. StringToCoTaskMemUni (tip );

Return S_ OK;
}

 

 

Code: http://files.cnblogs.com/lemony/MyContextMenu.rar

 

This chapter seems too simple. The next chapter describes how to use the IShellPropSheetExt interface to add an attribute page to a file/folder, as shown below:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.