www.pudn.com > COperation.rar > Operation.cpp


#include "Operation.h" 
#include "phone.h" 
#include "sms.h" 
#include "Wininet.h" 
 
 
COperation::COperation(void) 
{ 
} 
 
COperation::~COperation(void) 
{ 
} 
 
BOOL COperation::SendSMS(TCHAR * szDestination, TCHAR * szContent) 
{ 
	HRESULT hr; 
	SMS_HANDLE hSms = NULL; 
	hr = SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &hSms, NULL); 
 
	if(FAILED(hr)) 
	{ 
		return FALSE; 
	} 
 
	SMS_ADDRESS smsDestination; 
	SMS_MESSAGE_ID smsMsgId = 0; 
 
	memset(&smsDestination, 0, sizeof(SMS_ADDRESS)); 
	smsDestination.smsatAddressType = SMSAT_INTERNATIONAL; 
	_tcscpy(smsDestination.ptsAddress,TEXT("+86"));//国内手机必须在手机号码前加上+86 
	_tcscat(smsDestination.ptsAddress,szDestination); 
 
	DWORD dwMessageLength = 0; 
	TCHAR tchMessage[140] = TEXT("\0"); 
 
	_tcscpy(tchMessage, szContent); 
 
	dwMessageLength = lstrlen(tchMessage)*sizeof(TCHAR); 
 
	TEXT_PROVIDER_SPECIFIC_DATA txtProviderData; 
	DWORD dwProviderLenth = 0; 
	memset(&txtProviderData, 0, sizeof(TEXT_PROVIDER_SPECIFIC_DATA)); 
	txtProviderData.dwMessageOptions = PS_MESSAGE_OPTION_NONE; 
	txtProviderData.psMessageClass = PS_MESSAGE_CLASS1; 
	txtProviderData.psReplaceOption = PSRO_NONE; 
	DWORD dwProviderLength = sizeof(TEXT_PROVIDER_SPECIFIC_DATA); 
 
	hr = SmsSendMessage(hSms, NULL, &smsDestination, NULL,(BYTE*)tchMessage, dwMessageLength, (LPBYTE)&txtProviderData, 
		                dwProviderLength, SMSDE_OPTIMAL, SMS_OPTION_DELIVERY_NONE, &smsMsgId); 
 
	SmsClose(hSms); 
 
	if(FAILED(hr)) 
	{ 
		return FALSE; 
	} 
 
	return TRUE; 
} 
 
void COperation::CallOut(TCHAR * szDestination) 
{ 
	PHONEMAKECALLINFO info; 
	info.cbSize = sizeof(PHONEMAKECALLINFO); 
	info.dwFlags = PMCF_PROMPTBEFORECALLING; 
	info.pszDestAddress = szDestination; 
	info.pszAppName = NULL; 
	info.pszCalledParty = NULL; 
	info.pszComment = NULL; 
 
	PhoneMakeCall(&info); 
} 
 
void COperation::Browse(TCHAR  * szUrl) 
{ 
	SHELLEXECUTEINFO execInf; 
 
	ZeroMemory(&execInf, sizeof(execInf)); 
	execInf.cbSize = sizeof(execInf);  
	execInf.fMask = SEE_MASK_NOCLOSEPROCESS;  
	execInf.lpFile = szUrl; 
	execInf.lpVerb = TEXT("open"); 
 
	ShellExecuteEx(&execInf); 
}