zoukankan      html  css  js  c++  java
  • 【原创】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?? 困惑啊~~~~  

  • 相关阅读:
    LeetCode-1370 Increasing Decreasing String
    LeetCode-1221 Split a String in Balanced Strings
    Neo4j 实战(三)-- Neo4j Loads CSV Files
    Neo4j 实战(二)-- neo4j 基础语句
    Java HashMap 学习笔记
    Markdown 入门笔记
    《知识图谱方法、实践与应用》读书笔记(第一遍)
    Java 数组复制
    LeetCode-496 Next Greater Element I Solution(with Java)
    linux 同步IO: sync、fsync与fdatasync
  • 原文地址:https://www.cnblogs.com/hengfeng/p/1646586.html
Copyright © 2011-2022 走看看