WM 6.0에서 SMS 전송 하기
Windows Mobile 2009/05/11 13:52
#include "stdafx.h"
#include <sms.h>
#pragma comment(lib, "sms.lib")
void SendSMS(BOOL bSendConfirmation,
BOOL bUseDefaultSMSC,
LPCTSTR lpszSMSC,
LPCTSTR lpszRecipient,
LPCTSTR lpszMessage);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
SendSMS(FALSE,TRUE,L"",L"+14258828080",L"Hello SMS Message from CE 6.0!");
return 0;
}
void SendSMS(BOOL bSendConfirmation,
BOOL bUseDefaultSMSC,
LPCTSTR lpszSMSC,
LPCTSTR lpszRecipient,
LPCTSTR lpszMessage)
{
SMS_HANDLE smshHandle;
SMS_ADDRESS smsaDestination;
TEXT_PROVIDER_SPECIFIC_DATA tpsd;
SMS_MESSAGE_ID smsmidMessageID = 0;
TCHAR tcBuffer[1024];
memset(tcBuffer,0x00,1024);
StringCchCopy(tcBuffer, 1024, lpszMessage);
// try to open an SMS Handle
HRESULT hr = SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL);
if (hr != ERROR_SUCCESS) {
printf ("SmsOpen fail %x %d", hr, GetLastError());
return;
}
// Create the destination address
memset (&smsaDestination, 0, sizeof (smsaDestination));
smsaDestination.smsatAddressType = SMSAT_INTERNATIONAL;
lstrcpy(smsaDestination.ptsAddress, lpszRecipient);
// Set up provider specific data
tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE;
tpsd.psMessageClass = PS_MESSAGE_CLASS1;
tpsd.psReplaceOption = PSRO_NONE;
// Send the message, indicating success or failure
hr = SmsSendMessage (smshHandle, NULL, &smsaDestination, NULL,
(PBYTE) tcBuffer, (lstrlen(tcBuffer)+1)*sizeof(TCHAR),
(PBYTE) &tpsd, sizeof(TEXT_PROVIDER_SPECIFIC_DATA),
SMSDE_OPTIMAL,
SMS_OPTION_DELIVERY_NONE, &smsmidMessageID);
if (hr == ERROR_SUCCESS)
MessageBox(NULL,L"Message sent",L"SMS Test",MB_OK);
SmsClose (smshHandle);
}
< C# 에서 사용하기 >
SmsMessagesms= new SmsMessage("800-555-1212", "hello!");
sms.Send();
[출처] WM 6.0에서 SMS 전송 하기 |작성자 미뉴에트
'Windows Mobile' 카테고리의 다른 글
| Windows Mobile 기본 어플리케이션으로 등록하기 (0) | 2009/12/03 |
|---|---|
| Using Gestures in Windows Mobile 6.5 (0) | 2009/12/03 |
| C# 윈도우 폼 숨기기 (0) | 2009/09/15 |
| PDA 백라이트 조명 밝기 조정 레지스트리 (0) | 2009/09/10 |
| Windows Mobile 6.1.4 / 6.5 영문 Emulator에서 한글 출력하기 (0) | 2009/07/21 |
| WM 6.0에서 SMS 전송 하기 (1) | 2009/05/11 |
