Using Win32 functions in Visual FoxPro Image Gallery
Shell Functions
..msdn
AssocQueryString
DllGetVersion
DragAcceptFiles
DragFinish
DragQueryFile
DragQueryPoint
FileIconInit
FindExecutable
GetFileNameFromBrowse
GetMenuContextHelpId
GetWindowContextHelpId
InetIsOffline
IsUserAnAdmin
LoadUserProfile
PathMakeUniqueName
PathYetAnotherMakeUniqueName
RealDriveType
RestartDialog
SHAddToRecentDocs
SHBrowseForFolder
SHCreateDirectory
ShellAbout
ShellExecute
ShellExecuteEx
Shell_GetImageLists
Shell_NotifyIcon
SHEmptyRecycleBin
SHFileOperation
SHFormatDrive
SHGetFileInfo
SHGetFolderPath
SHGetPathFromIDList
SHGetSpecialFolderLocation
SHGetStockIconInfo
SHParseDisplayName
SHQueryRecycleBin
SHSimpleIDListFromPath
UnloadUserProfile
WinHelp
Code examples:
Browsing Windows Known Folders (Special Folders)
Detecting changes in connections to removable drives (VFP9)
Displaying the associated icons and descriptions for files and folders
System Image List Viewer
Windows Shell Icons displayed and exported to ICO files (Vista)
SHGetFileInfo
    Add comment     W32 Constants      Translate this page
Retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root.
Code examples:
Browsing Windows Known Folders (Special Folders)
Detecting changes in connections to removable drives (VFP9)
Windows Shell Icons displayed and exported to ICO files (Vista)
Displaying the associated icons and descriptions for files and folders
System Image List Viewer
Declaration:
DWORD_PTR SHGetFileInfo(
    LPCTSTR pszPath,
    DWORD dwFileAttributes,
    SHFILEINFO *psfi,
    UINT cbFileInfo,
    UINT uFlags
);
FoxPro declaration:
DECLARE INTEGER SHGetFileInfo IN shell32;
    STRING pszPath,;
    LONG dwFileAttributes,;
    STRING @psfi,;
    LONG cbFileInfo,;
    LONG uFlags
Parameters:
pszPath
[in] Pointer to a null-terminated string of maximum length MAX_PATH that contains the path and file name.

dwFileAttributes
[in] Combination of one or more file attribute flags.

psfi
[out] Address of a SHFILEINFO structure to receive the file information.

cbFileInfo
[in] Size, in bytes, of the SHFILEINFO structure pointed to by the psfi parameter.

uFlags
[in] Flags that specify the file information to retrieve.
Return value:
Returns a value whose meaning depends on the uFlags parameter.
My comment:
If SHGetFileInfo returns an icon handle (HICON) in the hIcon member of the SHFILEINFO structure pointed to by psfi.

Not so many applications in Visual FoxPro for this HICON handle I can think of. But there are two I am pretty sure about: displaying an icon in the System Tray, and displaying an icon inside the MessageBox dialog window.

The application is responsible for freeing the icon handle with DestroyIcon when it is no longer needed.

* * *
It seems that this function makes an addition to the system image list (aka Shell Icon Cache, HIMAGELIST), if the list has no element for the specified file type.

#DEFINE SHGFI_ICON 0x000000100
#DEFINE SHGFI_TYPENAME 0x000000400
#DEFINE SHGFI_USEFILEATTRIBUTES 0x000000010
#DEFINE FILE_ATTRIBUTE_NORMAL 0x00000080

*!*typedef struct _SHFILEINFO {
*!*        HICON hIcon;
*!*        int iIcon;
*!*        DWORD dwAttributes;
*!*        TCHAR szDisplayName[MAX_PATH];
*!*        TCHAR szTypeName[80];
*!*} SHFILEINFO;


LOCAL cFilename, nBufsize, cBuffer, nFlags,;
        nResult, hIcon

cFilename = ".xml"
nBufsize=1024
cBuffer = REPLICATE(CHR(0), nBufsize)
nFlags = BITOR(SHGFI_ICON,;
        SHGFI_TYPENAME, SHGFI_USEFILEATTRIBUTES)

nResult = SHGetFileInfo(cFilename, FILE_ATTRIBUTE_NORMAL,;
        @cBuffer, nBufsize, nFlags)

hIcon = buf2dword(SUBSTR(cBuffer, 1, 4))
IF hIcon <> 0
        = DestroyIcon(hIcon)
ENDIF

All system icons can be accessed through this function and drawn, for example, on ListView ActiveX control:



* * *
As MSDN suggests, the SHGetFileInfo may not be the best way, even if the simplest, to retrieve an object`s icon. A more flexible and efficient way is to use IExtractIcon Interface. The Shell uses IExtractIcon to retrieve icons when it displays the contents of a folder.
Word Index links for the SHGetFileInfo :
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
Created: 2007-05-12 19:38:59
Modified: 2011-01-20 10:24:25
Visited in last 7 days: 38
User Contributed Notes:
There are no notes on this subject.


Copyright 2001-2017 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.92.141.211)
5 sec.Function: 'SetupDiGetClassImageListEx'
9 sec.Function: 'InternetTimeToSystemTime'
14 sec.Function: 'FillMemory'
19 sec.Function: 'setsockopt'
25 sec.Function: 'GetOEMCP'
30 sec.Function: 'PathSearchAndQualify'
35 sec.Function: 'SetConsoleCursorPosition'
42 sec.Function: 'GetDoubleClickTime'
48 sec.Function: 'GdipCreateFontFamilyFromName'
54 sec.Function: 'UrlEscape'
Google
Advertise here!