• Symbian 利用Socket发送短信的源码(转)


    网上找到的源码,先做备份。下次肯定会用到~
    RSocketServ sockServ;
    User::LeaveIfError(sockServ.Connect());
    CleanupClosePushL(sockServ);
     
    RSocket socket;
    User::LeaveIfError(
        socket.Open(sockServ, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol));
    CleanupClosePushL(socket);
     
    TSmsAddr smsaddr;
    smsaddr.SetSmsAddrFamily(ESmsAddrSendOnly);
    smsaddr.SetPort(smsaddr.Port() + 1);
     
    User::LeaveIfError(socket.Bind(smsaddr));
     
    RFs fileSession;
    User::LeaveIfError(fileSession.Connect());
    CleanupClosePushL(fileSession);
     
    CSmsBufferBase *buffer = CSmsBuffer::NewL();
    CleanupStack::PushL(buffer);
     
     
    buffer->InsertL(0, _L("This is a test Message"));
     
    TSmsUserDataSettings smsSettings;
    smsSettings.SetAlphabet (TSmsDataCodingScheme::ESmsAlphabet8Bit);
    smsSettings.SetTextCompressed(EFalse);
     
    CSmsMessage *cSmsMessage = CSmsMessage::NewL(fileSession, CSmsPDU::ESmsSubmit, buffer);
    CleanupStack::Pop(buffer);
    CleanupStack::PushL(cSmsMessage);
    cSmsMessage->SetUserDataSettingsL(smsSettings);
    cSmsMessage->SetToFromAddressL(_L("98888888888888"));
    cSmsMessage->SmsPDU().SetServiceCenterAddressL(_L("+9999999"));
     
    RSmsSocketWriteStream writestream(socket);
    writestream << *cSmsMessage; 
    writestream.CommitL();
     
    TRequestStatus status;
    TPckgBuf<TUint> sendBuffer;
    socket.Ioctl(KIoctlSendSmsMessage, status, &sendBuffer, KSolSmsProv);
    User::WaitForRequest(status);
     
    CleanupStack::PopAndDestroy(cSmsMessage);
    CleanupStack::PopAndDestroy(&fileSession);
    CleanupStack::PopAndDestroy(&socket);
    CleanupStack::PopAndDestroy(&sockServ);
  • 相关阅读:
    bzoj 2763: [JLOI2011]飞行路线
    bzoj 2761: [JLOI2011]不重复数字
    bzoj 2744: [HEOI2012]朋友圈
    bzoj 2743: [HEOI2012]采花
    bzoj 2730: [HNOI2012]矿场搭建
    bzoj 2705: [SDOI2012]Longge的问题
    抗DDOS攻击
    kali安装后配置
    Kali更新源,亲测目前可用的源
    kali安装及配置ssr客户端
  • 原文地址:https://www.cnblogs.com/yaoliang11/p/1857432.html
Copyright © 2020-2023  润新知