|
MENUITEMINFO menuiteminfo;
DWORD dwErr = 0;
memset( &menuiteminfo, 0, sizeof(MENUITEMINFO) );
menuiteminfo.cbSize = sizeof( MENUITEMINFO );
menuiteminfo.fMask = 0x00000040;// MIIM_STRING;
menuiteminfo.fType = MFT_STRING | 0x00000080;//MIIM_BITMAP;
menuiteminfo.fState = MFS_ENABLED;
menuiteminfo.dwTypeData = NULL;
//add by ryo 2005.11.29, to modify the system EJECT menu item.
GetMenuItemInfo( hmenu, uEjectRealID, FALSE, &menuiteminfo );
menuiteminfo.cch++;
szInsEjt = (TCHAR*)malloc( (menuiteminfo.cch)*sizeof(TCHAR) );
if( szInsEjt == NULL )
return S_FALSE;
menuiteminfo.dwTypeData = szInsEjt;
if( !GetMenuItemInfo( hmenu, uEjectRealID, FALSE, &menuiteminfo ))
{
dwErr = GetLastError();
}
else
{
if( m_hBmp != NULL /*&& bSetBmp*/ )
{
if( !SetMenuItemBitmaps( hmenu, uEjectRealID, MF_BYCOMMAND, m_hBmp, NULL ))
dwErr = GetLastError();
}
}
ModifyMenu ( hmenu, uEjectRealID, MF_BYCOMMAND )
这个是虽然是ATL的,但是使用了同样的东西,给你参考下.
另:MSDN上说的很清楚,先要使用NULL给结构体得到cch的大小,然后才真正的进行操作,看你是否忽略了这个? |
|