Another classic and refreshing API of Win32, too powerful shgetfileinfo

Source: Internet
Author: User

Today, whimsy will learn (engage in) the design of desktop software in the future, because the quick and convenient desktop under Windows is loved by many netizens, in addition, a good desktop software can bring innegligible efficiency to friends who work on computers all the year round. It can even be pleasing to the eye, so that everyone can be put to rest. If the software is bloated, it will soon be buried by the public unless many users are particularly dependent on it.

No nonsense, just like the question.

Shgetfileinfo is a very practical API.

DWORD_PTR SHGetFileInfo(      
    LPCTSTR pszPath,    DWORD dwFileAttributes,    SHFILEINFO *psfi,    UINT cbFileInfo,    UINT uFlags);
Parameter 1: file path
Not explained
The third is the address with the structure name shfileinfo. This is actually maintained by the window, which we do not need to fill in.
The fourth is the shfileinfo size (simple ).
Five is very important. It depends on msdn.
PS: When obtaining an icon, you must specify whether it is large or small. Of course, the default icon is large. If it is smiling, you must specify it. You cannot directly specify large and small, this is ineffective.
Sfi_largeicon (sfi_smallicon) indicates that it is a modifier of sfi_icon. That is to say, sfi_largeicon (sfi_smallicon) cannot appear independently.
For details, refer to the Code implemented in VC:
\ MFC implementation (great)
Shfileinfo fileinfo;
: Zeromemory (& fileinfo, sizeof (fileinfo ));
: Shgetfileinfo (text (
"C: \ Documents and Settings \ Administrator \ Desktop \ dbgview.exe "),
0, & fileinfo, sizeof (fileinfo), shgfi_icon );
Hicon = fileinfo. hicon;
CDC * Dc = This-> getdc ();
DC-> drawicon (0, 0, hicon );


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.