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 );