呵呵,下面是一段拨号代码(摘自Nokia的例子),代码虽然不多,但很多地方都值得学习,例如:对R类的使用,清理;server/client机制;参数传递机制;编码风格;注释风格等等自己体会吧。
在阅读代码之前请熟悉Symbian OS C++中的ETel结构,以及它的核心类RTelServer,RPhone,RLine,RCall.
下面是代码内容:
void DialNumberL(const TDesC& aPhoneNumber)
{
//Create a connection to the tel server
RTelServer server;
CleanupClosePushL(server);
User::LeaveIfError(server.Connect());
//Load in the phone device driver
User::LeaveIfError(server.LoadPhoneModule(KTsyName));
//Find the number of phones available from the tel server
TInt numberPhones;
User::LeaveIfError(server.EnumeratePhones(numberPhones));
//Check there are available phones
if (numberPhones < 1)
{
User::Leave(KErrNotFound);
}
//Get info about the first available phone
RTelServer::TPho