Retrieving File Information

Assuming that you want to learn a little bit about the files being dropped in your application, you'll appreciate the SHELL32.DLL functions that execute a file, get the name and the handle of an executable file, parse command-line arguments, extract icons, and get file information. Many of these functions existed in previous versions of Windows, but some are new.

The FindExecutable and ShellExecute functions, which are not new, take advantage of file associations to find and start applications or to open and print files. By specifying a filename, you can use FindExecutable to get the name and the handle of the executable file that is started when an open association is run. (This function is supported only for compatibility with previous versions of Windows; it is not recommended for Win32-based applications.) ShellExecute either opens or prints a specified file. Your application designates which operation is performed by specifying open or print in the lpszOp parameter of the function. Pretty simple.

To get the icon associated with an executable, you can use the ExtractIcon function. This function returns the handle of an icon from a file that you specify—an executable file, a dynamic-link library, or an icon file. Once you have this handle, you can use it to draw the icon.