⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cl_autostart.cpp

📁 timer自通过活动对象应用
💻 CPP
字号:
#include <apmrec.h>#include <apmstd.h>#include "cl_autostart.h"const TUid KUidemAclAutostart={0x09A770B5};CclAutostart::CclAutostart():CApaDataRecognizerType(KUidemAclAutostart, CApaDataRecognizerType::ENormal){	iCountDataTypes = 1;}TUint CclAutostart::PreferredBufSize(){	// no buffer recognition yet	return 0;}TDataType CclAutostart::SupportedDataTypeL(TInt /*aIndex*/) const{	return TDataType();}void CclAutostart::DoRecognizeL(const TDesC& /*aName*/, const TDesC8&			      /*aBuffer*/){	// this function is never called}void CclAutostart::StartThread(){	TInt res = KErrNone;		//create a new thread for starting our application	RThread * startAppThread;	startAppThread = new RThread();		User::LeaveIfError( res = startAppThread->Create(		_L("Autostart starter"),		CclAutostart::StartAppThreadFunction,		KDefaultStackSize,		KMinHeapSize,		KMinHeapSize,		NULL,		EOwnerThread) );		startAppThread->SetPriority(EPriorityNormal/*EPriorityLess*/);		startAppThread->Resume();		startAppThread->Close();}TInt CclAutostart::StartAppThreadFunction(TAny* /*aParam*/){		//wait 5 seconds...	RTimer timer; // The asynchronous timer and ...	TRequestStatus timerStatus; // ... its associated request status	timer.CreateLocal(); // Always created for this thread.	// get current time (microseconds since 0AD nominal Gregorian)	TTime time;	time.HomeTime();	// add ten seconds to the time	TTimeIntervalSeconds timeIntervalSeconds(45);	time += timeIntervalSeconds;	// issue and wait	timer.At(timerStatus,time);	User::WaitForRequest(timerStatus);			// create a TRAP cleanup	CTrapCleanup * cleanup = CTrapCleanup::New();	TInt err;	if( cleanup == NULL )	{		err = KErrNoMemory;	}	else	{		TRAP( err, StartAppThreadFunctionL() );	}	delete cleanup;	
	
	if (err!=KErrNone) 		User::Panic(_L("autostart"), err);
	return err;}void CclAutostart::StartAppThreadFunctionL(){#ifdef __WINS__	const TUid starter_uid= { 0x05CCC0B0 };
	RApaLsSession ls;
	User::LeaveIfError(ls.Connect());
	CleanupClosePushL(ls);
	_LIT(filen, ""); // dummy
	TThreadId dummy;
	User::LeaveIfError( ls.StartDocument(filen, starter_uid, dummy) );
	CleanupStack::PopAndDestroy();
#else
	TFileName fnAppPath = _L("\\system\\apps\\starter\\starter.exe");
	RProcess server;

	CleanupClosePushL(server);
	User::LeaveIfError(server.Create(fnAppPath, _L("")));
	server.Resume();

	CleanupStack::PopAndDestroy();
#endif}EXPORT_C CApaDataRecognizerType* CreateRecognizer(){	CApaDataRecognizerType* thing = new CclAutostart();		//start thread for our application	CclAutostart::StartThread();	return thing;}// DLL entry pointGLDEF_C TInt E32Dll(TDllReason /*aReason*/){	return KErrNone;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -