dsUserCommand_ptr pUserCmd;
dsApp->CreateUserCommand( myApplication::appID, UserCommandName, UserCmdString, Description, L"path_and_file_name.bmp", L"path_and_file_name.png", dsUIState_Document, &Error, &pUserCmd );
dsMenuItem_ptr pMenu;
dsApp->AddMenu(myApplication::appID, dsUIState_Document, MENU_POSITION, UserCommandName, &pMenu);
dsString UserCmdID1;
pUserCmd->GetID( &UserCmdID1 );
dsMenuItem_ptr pMenuItem;
pMenu->InsertMenuItem(myApplication::appID, dsMenuItemType_UserCommand, 1, L"Open Notepad", UserCmdID1, &pMenu);
if( ( dsCreateCommand_Succeeded == Error ) && ( NULL != pUserCmd ) )
{
dsString ToolbarName = L"QAddIn1_Toolbar";
dsToolbar_ptr pToolbar;
dsApp->AddToolbar( myApplication::appID, dsUIState_Document, ToolbarName, &pToolbar );
if( NULL != pToolbar )
{
dsToolbarItem_ptr pToolbarItem;
dsString ButtonName = L"Notepad";
dsString UserCmdID;
pMenu->GetID( &UserCmdID );
pToolbar->InsertToolbarItem( myApplication::appID, dsToolBarItemType_UserCommand, 1, ButtonName, UserCmdID, &pToolbarItem );
}
}