void GetPhoneNumberCallLog()
{
TCHAR LastIncomingCall[40];
TCHAR LastMissedCall[40];
TCHAR LastOutGoingCall[40];
TCHAR LastIncomingCallName[256];
TCHAR LastMissedCallName[256];
TCHAR LastOutGoingCallName[256];
HANDLE ph;
CALLLOGENTRY entry;
DWORD count;
entry.cbSize = sizeof(CALLLOGENTRY);
if(PhoneOpenCallLog(&ph)== S_OK)
{
if(S_OK == PhoneSeekCallLog(ph, CALLLOGSEEK_BEGINNING, 0, &count))
//如果用CALLLOGSEEK_END那么count得到是的全部记录的个数
//如果用CALLLOGSEEK_BEGINNING那么count得是0
{
int lastIncallFlag = 0;
int lastMissedCallFlag = 0;
int lastOutgoingCallFlag = 0;
while(PhoneGetCallLogEntry(ph, &entry) == S_OK)
{
if(( !lastIncallFlag)&&(entry.iom != IOM_OUTGOING) && (!entry.fOutgoing) )
{
//MessageBox(NULL, entry.pszNumber, TEXT("Last Incoming Call"), 0);
lstrcpy(LastIncomingCall, entry.pszNumber);
if(!entry.pszName)
lstrcpy(LastIncomingCallName, TEXT("Unknow"));
else
lstrcpy(LastIncomingCallName, entry.pszName);
MessageBox(NULL,LastIncomingCall,LastIncomingCallName,0);
lastIncallFlag = 1;
}
if(( !lastMissedCallFlag) && (entry.iom == IOM_MISSED))
{
lstrcpy(LastMissedCall, entry.pszNumber);
if(!entry.pszName)
lstrcpy(LastMissedCallName, TEXT("Unknow"));
else
lstrcpy(LastMissedCallName, entry.pszName);
MessageBox(NULL,LastMissedCall,LastMissedCallName,0);
lastMissedCallFlag = 1;
}
if(( !lastOutgoingCallFlag) && (entry.iom == IOM_OUTGOING))
{
lstrcpy(LastOutGoingCall, entry.pszNumber);
if(!entry.pszName)
lstrcpy(LastOutGoingCallName, TEXT("Unknow"));
else
lstrcpy(LastOutGoingCallName, entry.pszName);
MessageBox(NULL,LastOutGoingCall,LastOutGoingCallName,0);
lastOutgoingCallFlag = 1;
}
// Make phone
/* PHONEMAKECALLINFO phonemakecall;
phonemakecall.cbSize = sizeof(PHONEMAKECALLINFO);
phonemakecall.dwFlags = PMCF_PROMPTBEFORECALLING;
phonemakecall.pszDestAddress = entry.pszNumber;
phonemakecall.pszAppName = NULL;
phonemakecall.pszCalledParty = NULL;
phonemakecall.pszComment = NULL;
PhoneMakeCall(&phonemakecall);*/
}
//Show the call log filter
//PhoneShowCallLog(CALLLOGFILTER_OUTGOING);
}
}
PhoneCloseCallLog (ph);
}
打开phone.h发现在WM5.0上有两个两个函数在SDK里是没有的
第一个是
HRESULT PhoneAddSpeedDial(DWORD dwFlags, DWORD* piKey, const TCHAR* pszDisplayName, const TCHAR* pszTelNumber);
第二个是
HRESULT PhoneShowCallLog(CALLLOGFILTER iCallLogFilter);
typedef enum
{
CALLLOGFILTER_ALL_CALLS,
CALLLOGFILTER_MISSED,
CALLLOGFILTER_INCOMING,
CALLLOGFILTER_OUTGOING
} CALLLOGFILTER;
//++++++
//
// PhoneAddSpeedDial
//
// adds a speed dial entry
//
// dwFlags - currently unused, set to 0
//
// piKey - in/out: the key sequence which will invoke the speed dial.
// currently an entry between 2 and 99 (inclusive) is valid.
// the API will cause existing entries to be overwritten
//
// pszDisplayName - the non-empty display name for the speed dial
//
// pszTelNumber - the non-empty tel# to be dialed
//
HRESULT PhoneAddSpeedDial(DWORD dwFlags, DWORD* piKey, const TCHAR* pszDisplayName, const TCHAR* pszTelNumber);