发送到普通手机上没问题,发送到SP提供商时软吗
int SendSMSForMobile(BOOL bSendConfirmation, BOOL bUseDefaultSMSC, LPCTSTR lpszSMSC, LPCTSTR lpszRecipient, LPCTSTR lpszMessage)
{
BOOL bRet = FALSE;
SMS_HANDLE smshHandle;
SMS_ADDRESS smsaSource;
SMS_ADDRESS smsaDestination;
TEXT_PROVIDER_SPECIFIC_DATA tpsd;
SMS_MESSAGE_ID smsmidMessageID;
// try to open an SMS Handle
if ( FAILED(SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL)) )
{
//MessageBox(NULL,
// (LPCTSTR)LoadString(ghInstance, IDS_ERROR_SMSOPEN, 0, 0),
// (LPCTSTR)LoadString(ghInstance, IDS_CAPTION_ERROR, 0, 0),
// MB_OK | MB_ICONERROR);
return DEV_ERROR;
}
// Create the source address
if (!bUseDefaultSMSC)
{
smsaSource.smsatAddressType = SMSAT_INTERNATIONAL;
_tcsncpy(smsaSource.ptsAddress, lpszSMSC, SMS_MAX_ADDRESS_LENGTH);
}
// Create the destination address
smsaDestination.smsatAddressType = SMSAT_INTERNATIONAL;
_tcsncpy(smsaDestination.ptsAddress, lpszRecipient, SMS_MAX_ADDRESS_LENGTH);
// Set up provider specific data
memset(&tpsd, 0, sizeof(tpsd));
tpsd.dwMessageOptions = bSendConfirmation ? PS_MESSAGE_OPTION_STATUSREPORT : PS_MESSAGE_OPTION_NONE;
tpsd.psMessageClass = PS_MESSAGE_CLASS1;
tpsd.psReplaceOption = PSRO_NONE;
tpsd.dwHeaderDataSize = 0;
// Send the message, indicating success or failure
if ( SUCCEEDED(SmsSendMessage(smshHandle, ((bUseDefaultSMSC) ? NULL : &smsaSource),
&smsaDestination, NULL, (PBYTE) lpszMessage,
_tcslen(lpszMessage) * sizeof(TCHAR), (PBYTE) &tpsd,
sizeof(TEXT_PROVIDER_SPECIFIC_DATA), SMSDE_OPTIMAL,
SMS_OPTION_DELIVERY_NONE, &smsmidMessageID)) )
{
//MessageBox(NULL,
// (LPCTSTR)LoadString(ghInstance, IDS_SMSSENT, 0, 0),
// (LPCTSTR)LoadString(ghInstance, IDS_CAPTION_SUCCESS, 0, 0),
// MB_OK);
bRet = TRUE;
}
else
{
//MessageBox(NULL,
// (LPCTSTR)LoadString(ghInstance, IDS_ERROR_SMSSEND, 0, 0),
// (LPCTSTR)LoadString(ghInstance, IDS_CAPTION_ERROR, 0, 0),
// MB_OK | MB_ICONERROR);
bRet = FALSE;
}
// clean up
VERIFY(SUCCEEDED(SmsClose(smshHandle)));
if (bRet)
return DEV_OK;
else
return DEV_ERROR;
}
SMS_HANDLE smshHandle;
SMS_ADDRESS smsaSource;
SMS_ADDRESS smsaDestination;
TEXT_PROVIDER_SPECIFIC_DATA tpsd;
SMS_MESSAGE_ID smsmidMessageID;
// try to open an SMS Handle
if(FAILED(SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL)))
{
return bRetVal;
}
// Create the destination address
smsaSource.smsatAddressType = SMSAT_UNKNOWN;
smsaDestination.smsatAddressType = SMSAT_UNKNOWN;
_tcsncpy(smsaDestination.ptsAddress, lpszRecipient, SMS_MAX_ADDRESS_LENGTH);
// 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;
// Send the message, indicating success or failure
if(SUCCEEDED(SmsSendMessage(smshHandle, NULL,
&smsaDestination, NULL, (PBYTE) lpszMessage,
_tcslen(lpszMessage) * sizeof(TCHAR), (PBYTE) &tpsd,
sizeof(TEXT_PROVIDER_SPECIFIC_DATA), SMSDE_OPTIMAL,
SMS_OPTION_DELIVERY_NONE, &smsmidMessageID)))
{
bRetVal = TRUE;
}
else
{
bRetVal = FALSE;
}
// clean up
SmsClose(smshHandle);