Witam,
srodowisko: VC++ 2008, WM 6.5 (HTC Sense 2.1)
mam taki problem: okazjonalnie (nie znalazlem reguly) wywala mi sie usuwanie notification funkcja CeClearUserNotification.
Notification dodaje tak:
bool setNotification(LPTSTR app, LPTSTR args, SYSTEMTIME sysTime)
{
HANDLE result;
UserNotificationTrigger nt;
memset(&nt, 0, sizeof(CE_NOTIFICATION_TRIGGER));
nt.dwSize = sizeof(UserNotificationTrigger);
nt.dwType = CNT_TIME;
nt.lpszApplication = app;
nt.lpszArguments = args;
nt.stStartTime = sysTime;
UserNotificationType unType;
memset(&unType, '\0', sizeof(unType));
result = CeSetUserNotificationEx(0, &nt, &unType);
if(!result)
{
//err(TEXT("CeSetUserNotificationEx NULL!"));
}
return (result != 0);
}
Usuwam tak:
bool UnregisterApp(LPCTSTR lpstrExe)
{
UserNotificationTrigger unt = {0};
DWORD dwHowMany = 0, dwBytesNeeded = 0;
CE_NOTIFICATION_INFO_HEADER *notify = NULL;
LPBYTE lpBuffer = NULL;
HANDLE* pHandles = NULL;
if( !CeGetUserNotificationHandles (NULL, 0, &dwHowMany) )
{
//err(( TEXT("CeGetUserNotificationHandles failed <%d>!"), GetLastError() ));
return false;
}
if( dwHowMany == 0 )
{
return true;
}
pHandles = new HANDLE[dwHowMany];
if( pHandles == NULL )
{
//err(( TEXT("pHandles is NULL") ));
return false;
}
if( !CeGetUserNotificationHandles ( pHandles, dwHowMany, &dwHowMany ))
{
//err(( TEXT("CeGetUserNotificationHandles failed!") ));
delete[] pHandles;
return false;
}
for( DWORD i = 0; i < dwHowMany; i++ )
{
CeGetUserNotification( pHandles[i], 0, &dwBytesNeeded, NULL);
lpBuffer = NULL;
lpBuffer = new BYTE[dwBytesNeeded];
if( lpBuffer == NULL )
{
//err(( TEXT("lpBuffer is NULL!") ));
continue;
}
memset( lpBuffer, 0, dwBytesNeeded );
if( CeGetUserNotification( pHandles[i], dwBytesNeeded, &dwBytesNeeded, lpBuffer ))
{
notify = (CE_NOTIFICATION_INFO_HEADER*) lpBuffer;
if( notify->pcent->lpszApplication )
{
if( _tcsstr( notify->pcent->lpszApplication, lpstrExe ) != NULL )
{
if( !CeClearUserNotification( pHandles[i] ) )
{
//err(( TEXT("CeClearUserNotification <%s> failed <%d>!"),
// notify->pcent->lpszApplication, GetLastError() ));
delete[] lpBuffer;
delete[] pHandles;
return false;
}
}
}
}
else
{
//err(( TEXT("CeGetUserNotification failed!") ));
}
delete[] lpBuffer;
}
delete[] pHandles;
return true;
}
Funkcja CeClearUserNotification( pHandles ) generuje lasterror o wartosci: 87 (ERROR_INVALID_PARAMETER).
Jak wczesniej zaznaczylem - nie moge znalezc reguly no i przyczyny. Aczkolwiek stosowalem te funcje tez na starszym urzadzeniu z WM 6.1 bez dodatkow typu manilla, htc sense itd. i wtedy nie bylo problemu.
Udalo sie komus rozwiazac taki problem?
Pzdr