MobileProgramming Windows CE Shell User Interface Elements

Programming Windows CE Shell User Interface Elements content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

One of the key tasks of adapting Win32 code to the CE shell is learning how to make applications and documents visible to the user. In the SysMenuGadgets example below, you’ll see how to add shortcuts to the HPC and HPC Pro desktop and how to add programs and documents to the Start menu.

Figure 1 – The SysMenuGadgets Example Running on an HPC 2000 Platform

You can see the full source code for the SysMenuGadgets program in code files linked to this example on the website.

Adding Shortcuts to the Start Menu

The SysMenuGadgets Example collects information from the SysMenuGadgetsDlgProc() and modifies the shell elements accordingly when the user clicks the “Update Shell” button. The “Update Shell” button has the dialog control ID “IDOK”, so it also dismisses the dialog immediately after it updates the shell. The rest of the example application behaves in familiar ways, so we’ll restrict our attentions to SysMenuGadgetsDlgProc()’s handling of the IDOK command.

First we get the check state of the “Add Start Menu Item” control, and if it is checked, we create a Start Menu program shortcut by calling SHCreateShortcut():

hWndCheckbox = GetDlgItem(hWnd, IDC_ADD_START );
bChecked = SendMessage( hWndCheckbox, BM_GETCHECK,0,0 );
if( bChecked )
  if ( ! SHCreateShortcut( 
      MessageBox( hWnd, 
                  TEXT("Couldn't Create Shortcut"), 
                  TEXT("ERROR!"), MB_OK );
       return FALSE;

The parameters to SHCreateShortcut(), in the order shown, are a null terminated string specifying the fully qualified name of the shortcut and a null terminated string specifying the fully qualified name of the shortcut’s target. By creating the shortcut in the directory “WindowsPrograms”, we automatically end up with a start menu shortcut for the program on the HPC and HPC Pro devices. If you want to have more flexibility in targeting, you can include the logic we used in the FindDirs example to retrieve the fully qualified path for the special folder “CSIDL_STARTMENU “

Removing a short cut is a straightforward matter, and we do this if the “Add StartMenu Item” control is unchecked:

  DeleteFile(TEXT("WindowsDesktopHelloWorld.lnk") );

Just delete the link file created by SHCreateShortcut(), using the file’s fully qualified, null terminated pathname.

Adding and Deleting Shortcuts Without Using the Start Menu

Here’s how you create a shortcut to an application if you don’t want it to show up on the start menu. This shortcut appears as an icon on the desktop, but it could appear in another location just as easily, also represented as an icon:

hWndCheckbox = GetDlgItem(hWnd,IDC_ADD_SHORTCUT );
bChecked = SendMessage( hWndCheckbox, BM_GETCHECK,0,0 );
if( bChecked )
  if ( ! SHCreateShortcut( 


Again, you delete this type of shortcut by calling DeleteFile() and passing the fully qualified, null terminated pathname of the link file.

Looking Ahead

In the next installment, we’ll see how to add application icons to the most-recently-used list and how to add application icons to the task bar.

Source Code

Download source: –

About the Author

Nancy Nicolaisen is a software engineer who has designed and implemented highly modular Windows CE products that include features such as full remote diagnostics, CE-side data compression, dynamically constructed user interface, automatic screen size detection, entry time data validation.

In addition to writing for, she has written several books including Making Win 32 Applications Mobile.

# # #

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories