Hey all,
I'm getting some strange behaviour when using SHnotificationAdd the code i'm using to add the notification is as follows.
char * szFunc = __FUNCTION__;
BUError(E_STANDARDPARAMS, L"CNOInt_Beep_notification start");
BU_TRY
{
if(pMsgBeepAlertData == NULL)
{
pMsgBeepAlertData = (SHNOTIFICATIONDATA*)BULocalAlloc(LMEM_ZEROINIT,sizeof(SHNOTIFICATIONDATA));
if(pMsgBeepAlertData == NULL)
{
BUWinError(WE_STANDARDPARAMS,L"%hs : failed to alloc memory",szFunc);
return FALSE;
}
}
SHNOTIFICATIONDATA oldNotifyData = {0};
oldNotifyData.cbStruct = sizeof(SHNOTIFICATIONDATA);
LRESULT lres = SHNotificationGetData(&IID_NewMsg,ICON_ID_MESSAGEBEEP,&oldNotifyData );
if (ERROR_SUCCESS == lres)
{
if (oldNotifyData.pszHTML) free((void *) oldNotifyData.pszHTML);
if (oldNotifyData.pszTitle) free((void *) oldNotifyData.pszTitle);
SetLastError(0);
LRESULT lres = SHNotificationRemove(&IID_NewMsg, ICON_ID_MESSAGEBEEP);
BUError(E_STANDARDPARAMS, L"SHNotificationRemove just called prior to add, lres=%u LastError=%u",lres,GetLastError());
}
else
{
BUError(E_STANDARDPARAMS, L"SHNotificationRemove NOT called - as notification dosn't exist lres=%u LastError=%u",lres,GetLastError());
}
pMsgBeepAlertData->cbStruct = sizeof(SHNOTIFICATIONDATA);
pMsgBeepAlertData->dwID = ICON_ID_MESSAGEBEEP;
pMsgBeepAlertData->npPriority = SHNP_ICONIC;
pMsgBeepAlertData->csDuration = 5;
pMsgBeepAlertData->hicon = NULL;
pMsgBeepAlertData->grfFlags = SHNF_STRAIGHTTOTRAY | SHNF_CRITICAL;
pMsgBeepAlertData->clsid = IID_NewMsg;
pMsgBeepAlertData->hwndSink = NULL;
pMsgBeepAlertData->pszHTML = L"";
pMsgBeepAlertData->pszTitle = L"New Message";
pMsgBeepAlertData->lParam = ICON_ID_MESSAGEBEEP;
SetLastError(0);
lres = SHNotificationAdd(pMsgBeepAlertData);
if (ERROR_SUCCESS != lres)
{
BUError(E_STANDARDPARAMS, L"SHNotificationAdd Failed, lres=%u LastError=%u",lres,GetLastError());
return FALSE;
}
BUError(E_STANDARDPARAMS, L"CNOInt_Beep_notification return true ,LastError=%u",GetLastError());
}
BU_CATCH_AND_LOG_ALL
return TRUE;
Trouble is that once it goes off, I get a second message beep afterwards.
Anyone have any idea why this occurs ???