Windows Mobile 6.5
A version of this page is also available for

This function creates a new item programmatically, as if an item were chosen from the global New drop-down menu.

HRESULT SHCreateNewItem(
  HWND hwndOwner,
  REFCLSID clsid


[in] Handle to the owner window of the new item.


[in] Class identifier of the new item.

This function returns NOERROR when it is successful.

When SHCreateNewItem is called, the OS sends an NMN_INVOKECOMMAND notification message to the window of the application hosting the New button. This gives the application the opportunity to handle the call itself. If the value returned from the hosting application is zero, then the OS calls CoCreateInstance on the CLSID obtained from that menu item's registry setting to instantiate an object representing the new item.

If the object is successfully instantiated, then the OS tries to obtain a pointer to an IPersistPropertyBag:IPersist interface for it by calling IUnknown::QueryInterface on it.

If the object supports the IPersistPropertyBag interface, then the OS sends an NMN_GETPROPERTYBAG notification message to the hosting application. If the application returns a non-zero value from the notification, then the OS uses the IPersistPropertyBag interface to load the property bag returned from the application. Otherwise, the OS calls IPersistPropertyBag::InitNew from the interface it had previously obtained.

If the object does not support the IPersistPropertyBag interface, then the OS queries the object for the INewMenuItemServer interface.

Windows Embedded CEWindows CE 3.0 and later
Windows MobilePocket PC 2000 and later

Community Additions