Tuesday, January 12, 2016

SmsSendMessage function call problem.




            


A copy online function. But always unable messages. SmsSendMessage function returns a negative value -211 ...
It is not what is not set correctly?
int SendShortMessage (void)
{
SMS_HANDLE smsHandle = NULL;
HRESULT x = SmsOpen (SMS_MSGTYPE_TEXT, SMS_MODE_SEND, & amp; smsHandle, NULL);
if (FAILED (SmsOpen (SMS_MSGTYPE_TEXT, SMS_MODE_SEND, & amp; smsHandle, NULL))) {
// MessageBox (NULL, _T ("SmsOpen Fail"), _T ("Send Sms Fail"), MB_ICONINFORMATION);
return 0;
}

SMS_ADDRESS smsaSource;
SMS_ADDRESS smsaDestination;

SMS_MESSAGE_ID smsmidMessageID = 0;
TEXT_PROVIDER_SPECIFIC_DATA tpsd;

//smsaSource.smsatAddressType = SMSAT_INTERNATIONAL;
// _ Tcsncpy (smsaSource.ptsAddress, _T ("+8613800871500"), SMS_MAX_ADDRESS_LENGTH);

smsaDestination.smsatAddressType = SMSAT_INTERNATIONAL;
_tcsncpy (smsaDestination.ptsAddress, _T ("+8613987555666"), SMS_MAX_ADDRESS_LENGTH);

tpsd.dwMessageOptions = / * bSendConfirmation PS_MESSAGE_OPTION_STATUSREPORT: * / PS_MESSAGE_OPTION_NONE;
?tpsd.psMessageClass = PS_MESSAGE_CLASS1;
tpsd.psReplaceOption = PSRO_NONE;
//tpsd.dwHeaderDataSize = 0;

LPCTSTR lpszMessage = _T ("1111111");
HRESULT h = SmsSendMessage (smsHandle, NULL, & amp; smsaDestination, NULL,
(PBYTE) lpszMessage, _tcslen (lpszMessage) * sizeof (TCHAR), (PBYTE) & amp; tpsd,
sizeof (TEXT_PROVIDER_SPECIFIC_DATA), SMSDE_OPTIMAL, SMS_OPTION_DELIVERY_NONE,
& Amp; smsmidMessageID);
if (SUCCEEDED (SmsSendMessage (smsHandle, NULL, & amp; smsaDestination, NULL,
(PBYTE) lpszMessage, _tcslen (lpszMessage) * sizeof (TCHAR), (PBYTE) & amp; tpsd,
sizeof (TEXT_PROVIDER_SPECIFIC_DATA), SMSDE_OPTIMAL, SMS_OPTION_DELIVERY_NONE,
& Amp; smsmidMessageID)))
{
// MessageBox (NULL, _T ("ok"), _T ("sendsms"), MB_ICONINFORMATION);
}
else
{
// MessageBox (NULL, _T ("Fail"), _T ("sendsms"), MB_ICONINFORMATION);
}
SmsClose (smsHandle);
return 0;
}
Reply:
Look at the top
Reply:
1:
if (FAILED ()) use, do not repeat with twice, anyway, I would not use the
HRESULT x = SmsOpen (SMS_MSGTYPE_TEXT, SMS_MODE_SEND, & amp; smsHandle, NULL);
if (FAILED (SmsOpen (SMS_MSGTYPE_TEXT, SMS_MODE_SEND, & amp; smsHandle, NULL)))
This is only required if (FAILED (x)) on the line. Here there is an if (SUCCEEDED (SmsSendMessage .....
I also sent a length of 12, rather than sizeof (TEXT_PROVIDER_SPECIFIC_DATA) this does not know there is no problem.
2:
I do not know is not a problem, you want to clean up
tpsdmemset (& amp; tpsd, 0, sizeof (TEXT_PROVIDER_SPECIFIC_DATA));
// Set up provider specific data
tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE;
tpsd.psMessageClass = PS_MESSAGE_CLASS1;
tpsd.psReplaceOption = PSRO_NONE;
tpsd.dwHeaderDataSize = 0;
Reply:
If there are problems, then more trouble, is that machine? If ppc's hard to say, if it is sp that need to be signed in order to use the
Reply:
Thank you get.
Reply:
How to get, ah, how I do not understand?

No comments:

Post a Comment