SMS_HANDLE smshHandle;SMS_ADDRESS smsaSource;SMS_ADDRESS smsaDestination;TEXT_PROVIDER_SPECIFIC_DATA tpsd;SMS_MESSAGE_ID smsmidMessageID;//尝试打开一个SMS句柄if(FAILED(SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL))){ MessageBox(NULL,L"Call to SmsOpen failed.",L"Error",MB_OK | MB_IConERROR); return;}//建立源地址if(!bUseDefaultSMSC){ smsaSource.smsatAddressType = SMSAT_INTERNATIONAL; _tcsncpy(smsaSource.ptsAddress, lpszSMSC, SMS_MAX_ADDRESS_LENGTH);}//建立目标地址smsaDestination.smsatAddressType = SMSAT_INTERNATIONAL;_tcsncpy(smsaDestination.ptsAddress, lpszRecipient, SMS_MAX_ADDRESS_LENGTH);//建立提供者特定数据tpsd.dwMessageOptions = bSendConfirmation ? PS_MESSAGE_OPTION_STATUSREPORT : PS_MESSAGE_OPTION_NONE;tpsd.psMessageClass = PS_MESSAGE_CLASS1;tpsd.psReplaceOption = PSRO_NONE;//发送消息,显示源或者失败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, L"Message sent", L"Success",MB_OK);}else{ MessageBox(NULL, L"SmsSendMessage Failed", L"Error",MB_OK | MB_IConERROR);}//清除VERIFY(SUCCEEDED(SmsClose(smshHandle))); |