版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://liangroger.blogbus.com/logs/59870296.html
23.3rd你要想调试控制台,就在epoc.ini里面加上textshell
24.//得到IAP ID
_LIT(KIapIdSettingName, "IAP//id");
// start a test connection
RSocketServ socketServ;
User::LeaveIfError(socketServ.Connect());
CleanupClosePushL(socketServ);
RConnection connection;
User::LeaveIfError(connection.Open(socketServ));
CleanupClosePushL(connection);
User::LeaveIfError(connection.Start());
// get the IAP ID
TUint32 iapId;
User::LeaveIfError(connection.GetIntSetting(KIapIdSettingName, iapId));
CleanupStack::PopAndDestroy(2); // connection, socketServ
25.
// Get the application UI from CEikonEnv
CYourApplicationAppUi* appui = (static_cast<CYourApplicationAppUi*>(iEikonEnv->AppUi()));
// Get the view you want
CSomeView* view = (CSomeView*)appui->View(TUid::Uid(ESomeViewId));
26.设置全屏
SetExtentToWholeScreen();
//and in the void HandleResourceChange( TInt aType );
if (ETrue)
{
SetExtentToWholeScreen();
}
else
{
if (aType == KEikDynamicLayoutVariantSwitch)
{
TRect mainPaneRect;
AknLayoutUtils::LayoutMetricsRect(
AknLayoutUtils::EMainPane, mainPaneRect );
SetRect(mainPaneRect);
}
}
27.CBA
//#include <avkon.rsg>
SwitchCbaL(TInt aResourceId)
{
if (aResourceId == 0)
aResourceId = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
CEikButtonGroupContainer* cba = Cba();
cba->SetCommandSetL(aResourceId);
cba->DrawNow();
}
HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EVRexCmdAppReturn:
{
DoReturnL();
break;
}
case EVRexCmdAppRecord:
{
DoRecordL();
break;
}
....
}
}
//in rss
RESOURCE CBA r_vrex_pause_stop
{
buttons =
{
CBA_BUTTON { id=EVRexCmdAppPause; txt = qtn_vrex_pause; },
CBA_BUTTON { id=EVRexCmdAppStop; txt = qtn_vrex_stop; }
} ;
}
RESOURCE CBA r_vrex_continue_return
{
buttons =
{
CBA_BUTTON { id=EVRexCmdAppContinue; txt = qtn_vrex_continue; },
CBA_BUTTON { id=EVRexCmdAppReturn; txt = qtn_vrex_return; }
} ;
}
...
28.//文件系统的简单使用
BaflUtils::PathExists()
BaflUtils::FileExists()
29.//手机屏幕大小
TPixelsTwipsAndRotation pixTwipsRot;
CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(pixTwipsRot);
TSize screensize = pixTwipsRot.iPixelSize;
30.指定大小内存清空
Mem::FillZ();
31.当要进行的操作是最急需处理的,即使UI事件也不能中断它,可以将本线程设为最高优先级:
RThread().SetPriority( EPriorityAbsoluteHigh );
......
RThread().SetPriority( EPriorityLess );
32.将8位字符填充到16位字符中
TInt16* aBuffer;
TInt8* p;
//add contents
aBuffe全为将p第j个8位字符填充到为空值的aBuffer中第i个16位字符中
33.线程中自己创建清除栈
创建了还不行,需要至少一个TRAP或TRAPD
TInt Fun( TAny* aPtr )
{
CTrapCleanup* cleanup = CTrapCleanup::New();
//判断是不是为空,不为空进入下一步
TRAPD( err, DoThread( aPtr ) );
delete cleanup;
return 0;
}
34.位图操作(读写位图,改变位图)TBitmapUtil
直接操作数据区:比如:你要自己处理像素数据,处理图像。使用数据区,是不是只能读和修改,不能增加数据。
Symbian中操作图片时,一般大于4K的图片,需要锁住图片内存
TBitmapUtil bmpUtil( iOffScrnBmp );
bmpUtil.Begin( TPoint( 0, 0 ) );
pData = (TUint8*)iOffScrnBmp->DataAddress();
bmpUtil.End();
35.读取文件内容到内存中
HBufC8* C×××Container::ReadFileLC(const TDesC& aFileName)
{
RFs rfs;
RFile file;
User::LeaveIfError(rfs.Connect());
CleanupClosePushL(rfs);
User::LeaveIfError(file.Open(rfs, aFileName, EFileRead));
CleanupClosePushL(file);
TInt size;
User::LeaveIfError(file.Size(size));
HBufC8* buf = HBufC8::NewLC(size);
TPtr8 bufPtr(buf->Des());
User::LeaveIfError(file.Read(bufPtr));
CleanupStack::Pop(); // buf
CleanupStack::PopAndDestroy(2); // file, rfs
CleanupStack::PushL(buf);
return buf;
}
36.模拟按键
RWsSession ws;
ws.Connect();
TRawEvent ev1;
ev1.Set(TRawEvent::EKeyDown, EStdKeyYes);
ws.SimulateRawEvent(ev1); // CAPABILITY Req. SwEvent
//User::After(1000000);
TRawEvent ev2;
ev2.Set(TRawEvent::EKeyUp, EStdKeyYes);
ws.SimulateRawEvent(ev2);
ws.Flush();
ws.Close();
37。桌面主程序即UID3为0x101FD64C(idle.exe)
38.检查盘符内存是否够用
TVolumeInfo volinfo;
TInt err=iFs.Volume(volinfo,EDriveC);//检查c盘下面剩余空间
if ( volinfo.iFree<(iFrameCount*iFrameSize))
{
//enough
}
devices
devices -setdefault @****
bldmake bldfiles
abld build armi urel
再在Carbide c++中编译sis
1、程序安装完后自启动设置:
PKG文件中,执行文件(app/ exe)后面加上:FR, RI,并且放在安装文件列表的最后一个,等所有资源安装后再自启动。
例:****.app",FR,RI
2、三版写文件的一种方法。TFileText,逐行读取数据。
RFs fs;
RFile iFile;
User::LeaveIfError(fs.Connect());
iFile.Open(fs,KFilename,EFileRead|EFileShareAny);
TFileText lineRead;
lineRead.Set(iFile);
lineRead.Seek(ESeekStart);
TBuf<256> temp;
lineRead.Read(temp);
......
lineRead.Read(temp);
......
iFile.Close;
fs.Close;
///
RFs fs;
fs.Connect();
RFile file;
_LIT(KFilename,"c://weather.xml");
// if(BaflUtils::FileExists(fs,KFilename))
// {
// file.Replace(fs,KFilename,EFileStreamText|EFileWrite|EFileShareAny);
// }
// else
// {
// file.Create(fs,KFilename,EFileWrite|EFileShareAny);
// }
// file.Write(0,iFeedText);
file.Open(fs,KFilename,EFileRead|EFileShareAny);
file.Read(iFeedText);
file.Close();
fs.Close();
3、在类的const函数中使用并改变类的普通变量的值.
void CClassU::Draw(const TRect& aRect) const
{
((CClassU*)this)->index = 0;//index是CClassU类的普通变量
}
4.
TInt CCallElfAppUi::cInt(const TDesC& aStrInt)
{
TBuf8<10> aNum;
aNum.Copy(aStrInt);
TLex8 lex8(aNum);
TInt iNum;
TInt ret = lex8.Val(iNum);
if (ret != KErrNone)
{
return 0;
}
else
{
return iNum;
}
}
5.
和C++没有区别
~ 按位非 ~expr
<< 左移 expr1 << expr2
>> 右移 expr1 >> expr2
& 按位与 expr1 & expr2
^ 按位异或 expr1 ^ expr2
| 按位或 expr1 | expr2
&= 按位与赋值 expr1 &= expr2
^= 按位异或赋值 expr1 ^= expr2
|= 按位或赋值 expr1 |= expr2
6.快捷使用方法
template <class T>
inline TBool Rng(T aMin,T aVal,T aMax)
{return(aVal>=aMin && aVal<=aMax);}
7.手机桌面UID
/*
SDK UID Process Name
2nd edition 0x100058b3 (Phone)
3rd edition 0x100058b3
3rd edition and 3rd edition FP1 0x101fd64c (Standby Mode)
3rd edition FP2 0x102750F0 (Standby Mode)
5th edition 0x102750F0
*/