refresher.c
来自「Приложение предназначено для обновления 」· C语言 代码 · 共 138 行
C
138 行
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "AEEAppHist.h"
#include "Refresher.bid"
typedef struct _Refresher {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
// add your own variables here...
} Refresher;
static boolean Refresher_HandleEvent(Refresher* pMe,
AEEEvent eCode, uint16 wParam,
uint32 dwParam);
boolean Refresher_InitAppData(Refresher* pMe);
void Refresher_FreeAppData(Refresher* pMe);
void Refresher_UpApp(Refresher* pMe);
boolean Refresher_CheckApp(Refresher* pMe);
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_REFRESHER )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(Refresher),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)Refresher_HandleEvent,
(PFNFREEAPPDATA)Refresher_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(Refresher_InitAppData((Refresher*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);
}
static boolean Refresher_HandleEvent(Refresher* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
switch (eCode)
{
case EVT_APP_START:
ISHELL_StartApplet(pMe->a.m_pIShell, 0x0107F149);
ISHELL_SetTimer(pMe->a.m_pIShell, 3000, (PFNNOTIFY)Refresher_UpApp, pMe);
return(TRUE);
case EVT_APP_STOP:
return(TRUE);
case EVT_APP_SUSPEND:
return(TRUE);
case EVT_APP_RESUME:
return(TRUE);
case EVT_APP_MESSAGE:
return(TRUE);
case EVT_KEY:
return(TRUE);
default:
break;
}
return FALSE;
}
boolean Refresher_InitAppData(Refresher* pMe)
{
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
return TRUE;
}
// this function is called when your application is exiting
void Refresher_FreeAppData(Refresher* pMe)
{
}
void Refresher_UpApp(Refresher* pMe)
{
if(Refresher_CheckApp(pMe)){
ISHELL_StartApplet(pMe->a.m_pIShell, 0x0107F149);
ISHELL_SetTimer(pMe->a.m_pIShell, 200, (PFNNOTIFY)Refresher_UpApp, pMe);
}
else
ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE);
}
boolean Refresher_CheckApp(Refresher* pMe)
{
IAppHistory * pHistory;
AEECLSID pcls;
boolean result = FALSE;
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_APPHISTORY, (void**)&pHistory);
if (!pHistory)
return TRUE;
IAPPHISTORY_GetClass(pHistory, &pcls);
if (pcls == 0x0107F149)
result = TRUE;
IAPPHISTORY_Release(pHistory);
return result;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?