包含头文件 #include <Etel3rdParty.h> #include <sysutil.h> 版本枚举值 public: enum TSDKVersion { E2RD, E3RD_FP0, E3RD_FP1, E3RD_FP2, E5RD }; 获取版本的函数 TInt GetS60PlatformVersionL() { TUint aMajor; TUint aMinor; TFindFile ff( CEikonEnv::Static()->FsSession()); CDir* result; _LIT(KS60ProductIDFile, "Series60v*.sis"); _LIT(KROMInstallDir, "z://system//install//"); User::LeaveIfError( ff.FindWildByDir( KS60ProductIDFile, KROMInstallDir, result ) ); CleanupStack::PushL( result ); User::LeaveIfError( result->Sort( ESortByName|EDescending ) ); aMajor = (*result)[0].iName[9] - '0';//3 aMinor = (*result)[0].iName[11] - '0';//1 CleanupStack::PopAndDestroy(); // result if(TInt(aMajor) == 5) { return E5RD; } else if(TInt(aMajor) == 3) { if(TInt(aMinor) == 0) { return E3RD_FP0; } else if(TInt(aMinor) == 1) { return E3RD_FP1; } else if(TInt(aMinor) == 2) { return E3RD_FP2; } } } 调用过程 void HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination) { TUid aUidIdleApp; TInt aVersionID = GetS60PlatformVersionL(); if(aVersionID == E3RD_FP0) { aUidIdleApp.iUid = 0x100058b3; } else if(aVersionID == E3RD_FP1) { aUidIdleApp.iUid = 0x101FD64C; } else if(aVersionID == E3RD_FP2) { aUidIdleApp.iUid = 0x102750F0; } else if(aVersionID == E5RD) { aUidIdleApp.iUid = 0x102750F0; } else if(aVersionID == E2RD) { aUidIdleApp.iUid = 0x100058b3; } const TUid KUidSelfApp = { 0xEF2E5AB1 }; if ( aEvent.Type() == EEventFocusGroupChanged ) { // 获取当前焦点程序的UID RWsSession& ws = iEikonEnv->WsSession(); TInt wgid = ws.GetFocusWindowGroup(); CApaWindowGroupName* gn = CApaWindowGroupName::NewLC(ws, wgid); TUid aCurAppUid = gn->AppUid(); TBuf<128> aTemp; aTemp.AppendNum(aCurAppUid.iUid); aTemp.Append(_L("/r/n")); WRITE_LOG16L(aTemp); CleanupStack::PopAndDestroy(gn); if (aCurAppUid==aUidIdleApp) { // 当前为桌面 } else { } if (aCurAppUid==KUidSelfApp) { } else { 、 } } CAknAppUi::HandleWsEventL(aEvent, aDestination); }