|
仿照sdk里面的发短信的例程,改写了一段代码,遇到了问题
[复制链接]
仿照sdk里面的发短信的例程,改写了一段代码,不知道怎么回事,总是发送不成功,请高手帮我看看 问题出在哪?
- SMS_HANDLE smshHandle;
- SMS_ADDRESS smsaSource;
- SMS_ADDRESS smsaDestination;
- TEXT_PROVIDER_SPECIFIC_DATA tpsd;
- SMS_MESSAGE_ID smsmidMessageID;
- BOOL bRetVal=FALSE;
- LPCTSTR lpszRecipient;
- LPCTSTR lpszMessage;
- UpdateData();
- lpszRecipient=m_receiver;
- lpszMessage=m_msg;
- // try to open an SMS Handle
- if(FAILED(SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL)))
- {
- //return bRetVal;
- bRetVal=FALSE;
- }
- // Create the destination address
- smsaSource.smsatAddressType = SMSAT_NATIONAL;
- smsaDestination.smsatAddressType = SMSAT_NATIONAL;
- _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;
- AfxMessageBox(_T("Send SMS succussful!"));
- }
- else
- {
- bRetVal = FALSE;
- }
- // clean up
- VERIFY(SUCCEEDED(SmsClose(smshHandle)));
复制代码
|
|