• 【原创】Windows Mobile上C#发送短信失败问题...Help!!!


      在基于Windows Mobile平台上的CDMA智能机上可以通过调用WM提供的API来实现发短信:

      HRESULT hr =S_OK;
      SMS_HANDLE m_smshHandle = NULL;
      SMS_ADDRESS smsaDestination;
      TEXT_PROVIDER_SPECIFIC_DATA tpsd;

      SMS_MESSAGE_ID smsmidMessageID;

       memset(&smsaDestination, 0, sizeof(SMS_ADDRESS));
       memset(&tpsd, 0, sizeof(TEXT_PROVIDER_SPECIFIC_DATA));

      
       LPTSTR smsContent = TEXT("10001");

       hr = SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &m_smshHandle, NULL);
       if (hr == S_OK)
       {

          // Create the destination address
          smsaDestination.smsatAddressType =SMSAT_NATIONAL;
          wcscpy(smsaDestination.ptsAddress, TEXT("10000"));

          // Set up provider specific data
          memset(&tpsd, 0, sizeof(tpsd));
          tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE;
          tpsd.psMessageClass = PS_MESSAGE_CLASS1;
          tpsd.psReplaceOption = PSRO_NONE;
          tpsd.dwHeaderDataSize = 0;
          tpsd.tpsPriority = TEXTPSPRI_NORMAL;
          tpsd.dwExtParams = TEXTPSEXTPARM_PRIORITY;


          // Send the message, indicating success or failure
          hr = SmsSendMessage(m_smshHandle, NULL, &smsaDestination, NULL, (PBYTE)smsContent, 
             _tcslen(smsContent) * sizeof(TCHAR), (PBYTE)&tpsd, sizeof(TEXT_PROVIDER_SPECIFIC_DATA), 
             SMSDE_OPTIMAL, SMS_OPTION_DELIVERY_NONE, &smsmidMessageID);

       }

     

      但是使用C#发送短信却每次都失败:

      SmsMessage sms = new SmsMessage("10000", "10001");
      sms.Send();

      虽然代码上更加精简,但为什么老是发送不成功呢???是WM系统的问题?RIL?还是Modem?? 困惑啊~~~~  

  • 相关阅读:
    搭建MHA问题汇总
    NOIP2009 靶形数独
    get_mysql_conn_info.py
    NOIP 2005 篝火晚会
    MySQL启动关闭添加到 /etc/init.d/mysqld
    noip2002 矩形覆盖
    get_slave_status.py
    [JSOI2008]魔兽地图
    MySQL数据导出导入任务脚本
    8.30 牛客OI赛制测试赛1 F题 子序列
  • 原文地址:https://www.cnblogs.com/hengfeng/p/1646586.html
Copyright © 2020-2023  润新知