Search code examples
windowswinapiwindows-shell

How to show shell hint (text that appears when hovering a file in Explorer) for a file programmatically


This is what I want to get:

enter image description here

I know it's possible to get because Total Commander shows exactly the same info, although in a differently styled window. Which makes me think that there must be a way of querying this text for any given file.


Solution

  • The IQueryInfo interface is what you want. Briefly (psuedo-code only, sorry):

    PCUITEMID_CHILD pidl = <PIDL of item in question>
    IShellFolder* psf = <IShellFolder parent folder of item in question>
    
    IQueryInfo* pqi;
    if (SUCCEEDED(psf->GetUIObjectOf(hWnd, 1, &pidl, 0, &pqi)))
    {
        LPWSTR lpszTip;
        if (SUCCEEDED(pqi->GetInfoTip(0, &lpszTip)) && lpszTip)
        {
            // do something with the tip, and then free it
            CoTaskMemFree(lpszTip); 
        }
    }
    

    Once you have the text you can, of course, display it any way you like.