The information in this article applies to:
SUMMARY
The CtxMenu.exe sample shows the steps involved in displaying a
context menu, given the path to a file name. This is the same menu that is
displayed by Explorer when the context menu for a file is invoked.
Case 1: When the File Name Is a RootIn the case when the given file name is a root, the parent folder is "My Computer." To obtain the IShellFolder of MyComputer, we need to get the pidl to My Computer by using SHGetSpecialFolderLocation for CSIDL_DRIVES. We can get the IShellFolder of MyComputer by passing this pidl to the desktop folder's BindToObject. Once the IShellFolder of MyComputer is obtained, ParseDisplayName can be used to get the pidl of the given file name with respect to MyComputer's IShellFolder. Then the context menu interface of IShellFolder of MyComputer can be obtained by calling GetUIObjectOf with IID_IContextMenu. Once the context menu interface is obtained, QueryContextMenu can be used to get all the context menu items.Case 2: When the File Name Is Not a Root FolderIn the case when the given file name is not a root folder, then the file name is parsed to obtain the parent folder. The path to the parent folder is passed to desktop folder's ParseDisplayName to get the pidl. Using this pidl, the IShellFolder of the parent folder can be obtained by using the desktop IShellFolder's BindToObject. Then ParseDisplayName can be used to get the pidl of the given file name with respect to its parent's IShellFolder. Now the context menu interface of IShellFolder of the parent folder can be obtained by calling GetUIObjectOf with IID_IContextMenu. Once the context menu interface is obtained, QueryContextMenu can be used to get all the context menu items.MORE INFORMATIONThe following file is available for download from the Microsoft
Download Center. Click the file name below to download the file: CtxMenu.exeRelease Date: Jan. 15, 1999 For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. Additional query words:
Keywords : kbfile kbsample kbNTOS400 kbSDKWin32 kbWinOS95 kbWinOS98 |
Last Reviewed: December 20, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |