Getting File Interface Information

Open up Windows Explorer, and set the display mode to Details. You’ll see some information that we all know how to get as well as some you probably haven’t seen before and don’t know how to deal with in Visual Basic.

Notice that Windows Explorer lists some filenames with extensions and some without. Actually, Windows Explorer isn’t showing filenames at all. You are seeing display names, which you can get by calling the SHGetFileInfo API function. Windows creates a display name based on information registered for the file document type. If a file doesn’t have a registered document type, the shell will report the full filename, including the extension, as the display name. Generally, Windows uses the extension to determine the document type. In some cases, the system can use a binary pattern in the first part of the file to distinguish documents that have the same extension. COM structured storage files have a file type unrelated to any extension.

When you get the display name, you can also get other information from SHGet­FileInfo, including the file type string, the file attributes, the executable type, and various forms of large and small icons. All this comes from the registry entry for the document type. (Windows has defaults for files that have no document file type.) SHGetFileInfo will also work on directories, disk drives, and special folder locations such as My Computer, Network Neighborhood, Desktop, and Recycle Bin.