How to get an icon for other programs in the program?

zhaozj2021-02-11  264

How to get an icon for other programs in the program? Two methods: (1) SDK function SHGETFILEINFO, or use Extractic to get the Handle of the icon resource, (2) SDK function SHGETFILEINFO gets a lot of information about files, such as size icons, properties, types, etc. EXAMPLE (1): Display the NotePad icon in the upper left corner of the program window. Void CsampleView: OnDraw (CDC * PDC) {if (: ShgetFileInfo (_T ("C: //pwin95/notepad.exe"), 0, & StFileInfo SIZEOF (STFILEINFO), SHGFI_ICON) {PDC -> Drawicon (10, 10, stfileinfo.hicon)}} EXAMPLE (2): The same feature, Use Extracticon Functionvoid CsampleView :: Ondraw (CDC * PDC) {Hicon Hicon =: : Extracticon (AFXGetInstanceHandle (), _ T ("NOTEPAD.EXE"), 0) IF (Hicon && Hicon! = (HICON) -1) PDC-> Drawicon (10, 10, hicon)} Description: Get the path to NOTEPAD.EXE FRANTRORMENTS Function with the getWindowsDirectory function, if it is a brush to call Win95, you should use the way to access the registry to get its path. To make a more elegant program, consider the full point.

转载请注明原文地址:https://www.9cbs.com/read-3885.html

New Post(0)