16.2 Creating the Entry-Point Function

File Manager communicates with an extension DLL through the FMExtensionProc function. Be sure to export this function by listing it in an EXPORTS statement of your module-definition (.DEF) file. The FMExtensionProc function handles the messages listed in the previous section, performing the following tasks:

Task Action

Initializing the extension (FMEVENT_LOAD) Provides File Manager with the name and handle of the menu and saves the menu-item delta value.
Initializing the menu (FMEVENT_INITMENU) Initializes all top-level menu items and the items in any submenus.
Processing menu selections Carries out commands that the user chooses from the extension's menu.
Processing file selections (FMEVENT_SELCHANGE) Queries File Manager for information about the file that the user has selected from the directory window or Search Results window. For information about using the FM_GETFILESEL message to retrieve information about a selected file, see the Microsoft Windows Programmer's Reference, Volume 3.
Updating items in the menu (FMEVENT_USER_REFRESH) Modifies the menu as appropriate when the user chooses File Manager's Refresh command from the Window menu.
Quitting the extension DLL (FMEVENT_UNLOAD) Frees any memory allocated and prepares to exit.

The FMExtensionProc function is defined as follows:

HMENU FAR PASCAL FMExtensionProc(hwnd, wMsg, lParam)
HWND hwnd;
WORD wMsg;
LONG lParam;

The hwnd parameter identifies the File Manager window. An extension should use this window handle to specify the parent window for any dialog boxes or message boxes it needs to display. It should also use this handle to send query messages to File Manager. The wMsg parameter contains one of the File Manager messages listed previously. The lParam parameter contains a message-dependent value. The return value from the FMExtensionProc function depends on the value of the wMsg parameter.

The menu added to File Manager may be a hierarchical (cascaded) menu and may contain grayed, disabled, or checked menu items in addition to command items. Menu items should be text only; owner-drawn menus and bitmap menus are not supported. Changing the check-mark bitmap is not supported.

Whenever File Manager calls the FMExtensionProc function, it waits to refresh its directory windows (for changes in the file system) until after the function returns. This allows the extension to perform large numbers of file operations without excessive repainting on the part of File Manager. The extension does not need to send the FM_REFRESH_WINDOWS message to notify File Manager to repaint its directory windows.