How to use SimWriteMessage ?

My SMS message application need to write a sms message to sim card, it call SimWriteMessage function, It return 0x80070057(E_INVALIDARG), I change the input parameter's value and retry it, BUT it always return 0x80070057(E_INVALIDARG).

does anybody know how to use it

the follow is my source codes, it run in the windows mobile pocket PC phone emulator or a windows mobile pocket PC handset.

// source codes:
{
HRESULT hr;
DWORD dwMsgIndex;
DWORD dwTmp;
SIMMESSAGE SmsMsg;

memset( &SmsMsg, 0, sizeof(SmsMsg) );
SmsMsg.cbSize = sizeof( SmsMsg );
SmsMsg.dwParams = SIM_PARAM_MSG_ALL;
wcscpy( (SmsMsg.lpszAddress), TEXT("+8613812345678") );
SmsMsg.dwAddressType = SIM_ADDRTYPE_INTERNATIONAL;
SmsMsg.dwNumPlan = SIM_NUMPLAN_NATIONAL;
//GetSystemTime( &(SmsMsg.stReceiveTime) );
SmsGetTime( &(SmsMsg.stReceiveTime), &dwTmp );
SmsMsg.cbHdrLength = 0;
//strcpy( (char*)(SmsMsg.rgbHeader), "" );
wcscpy( (SmsMsg.lpszMessage), TEXT("Received sms message.") );

dwMsgIndex = 0;
hr = SimWriteMessage( g_SimInfo.hSimCard, SIM_SMSSTORAGE_SIM, &dwMsgIndex, (SIMMESSAGE*)&SmsMsg );
}


Thank you for your reading.




Answer this question

How to use SimWriteMessage ?

  • Eyso Zanstra

    Yes, I have tried it. I found I set dwNumPlan = SIM_NUMPLAN_TELEPHONE; maybe you can try it.


  • JDWCLG

    Hi,

    Since you don't use SmsMsg.rgbHeader, I think you should set SmsMsg.dwParams = SIM_PARAM_MSG_ALL & ~SIM_PARAM_MSG_HEADER;

    Thanks


  • mtm81

    But I do really develop the application in Visual Studio 2005,

  • myoungbl

    Hello.

    Can you send me email too

    I have trouble as well.

    I think your sample code really helps to me.

    minsik188@naver.com



  • jibotang

    But, My test result is unsuccessfull, Could you send you sample code to me

    Chen.kline@gmail.com



  • SBProgrammer

    you should call SimInitialize at first and call CloseHandle in the end.
  • monkeynova

    Thank you,

    But, I have tried it, Fail too.

    SIM_PARAM_MSG_ALL & ~(DWORD)SIM_PARAM_MSG_HEADER;// & ~(DWORD)SIM_PARAM_MSG_HEADER_LENGTH;

    Did you test your method



  • ash_78

    I've sent it to you. Because it's a privileged API, make sure you have provisioned your device with privilege and signed the code. Hope it will help.


  • trej

    This forum is primarily monitored by Visual Studio for devices group. Please check this link for more appropriate forum for this type of queries

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=286724&SiteID=1

    Thanks

    Srikanth Bogadapati



  • How to use SimWriteMessage ?