A place full of passion - Crius  
人生每一天都在进步。
日历
<2010年3月>
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
统计
  • 随笔 - 13
  • 文章 - 0
  • 评论 - 1
  • 引用 - 0

导航

常用链接

留言簿

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 

//获得SIM中联系人信息。
LPARAM DoShowSimContact(HWND hWnd, WORD idItem, HWND hwndCtl, WORD wNotifyCode)
{
 MessageBox(NULL, TEXT("start show sim contact"),TEXT("info"),MB_YESNO);
 HSIM lphSim;
 HRESULT hr = SimInitialize(0, NULL, 0, &lphSim);
 if(FAILED(hr))  
 {
  MessageBox(NULL, TEXT("initialize failure!"),TEXT("error"),MB_YESNO);
  return 0 ;
 }

 DWORD dwUsed,dwTotal;  
 hr = SimGetPhonebookStatus(lphSim, SIM_PBSTORAGE_SIM, &dwUsed, &dwTotal);

 TCHAR buf[20];

 swprintf(buf, TEXT("dwUsed = %d"), dwUsed);

 MessageBox(NULL, buf ,TEXT("dwUsed"),MB_YESNO);
 for(int i=0; i<dwUsed; i++)      
 {

  //对结构初始话以下  
  SIMPHONEBOOKENTRY phoneent;  
  memset(&phoneent,0,sizeof(phoneent));  
  phoneent.cbSize = sizeof(phoneent);
  if (SUCCEEDED(SimReadPhonebookEntry(lphSim, SIM_PBSTORAGE_SIM, i+1, &phoneent)))
  {
   TCHAR name[32];
   TCHAR phone[32];
MessageBox(NULL, phoneent.lpszText ,TEXT("info1"),MB_YESNO);
   wcsncpy(name, phoneent.lpszText,31); // 姓名
   wcsncpy(phone, phoneent.lpszAddress,31); // 电话
            _tcscat(name, phone);
   MessageBox(NULL, name ,TEXT("info"),MB_YESNO);
   
  }

   
 }

 //最后别忘了清理      
 SimDeinitialize(lphSim);
 lphSim = NULL;


    return 0;
}


//获得Outlook联系人信息

BOOL GetOutlookContacts(IPOutlookItemCollection * pItemCol)
{
 BSTR bstrFirstName;
 BSTR bstrLastName;
 BSTR bstrPhoneNumber;
 BSTR bstrContactInfo;
 
 
 IContact * pContact = NULL;
 int cItems = 0;
 
 pItemCol->get_Count(&cItems);
 
 for (int i = 1; i <= cItems; i++)
 {
  if (SUCCEEDED(pItemCol->Item (i, reinterpret_cast<IDispatch**>(&pContact))))
  {
   // grab properties
   pContact->get_FirstName(&bstrFirstName);
   pContact->get_LastName(&bstrLastName);
   pContact->get_HomeTelephoneNumber(&bstrPhoneNumber);

   // allocate a buffer for all the properties plus a comma, space. newline, and terminating null
   bstrContactInfo = SysAllocStringByteLen(NULL, SysStringByteLen(bstrFirstName) +
      SysStringByteLen(bstrLastName) +
      SysStringByteLen(bstrPhoneNumber) +
      (4*sizeof(OLECHAR)));
  
   // copy the strings into one
   _tcscpy(bstrContactInfo, bstrLastName);
   _tcscat(bstrContactInfo, _T(", "));
   _tcscat(bstrContactInfo, bstrFirstName);
   _tcscat(bstrContactInfo, _T("\n"));
   _tcscat(bstrContactInfo, bstrPhoneNumber);
 
   // add it to the listview
   AddToList(bstrContactInfo);

   // clean up
   SysFreeString(bstrFirstName);
   SysFreeString(bstrLastName);
   SysFreeString(bstrPhoneNumber);
   SysFreeString(bstrContactInfo);
   pContact->Release();
  }
 }
 if(!AddSIMContactsFolderText())
 {
  MessageBox(NULL, TEXT("add sim failure!"),TEXT("error"),MB_YESNO);

 }
 return TRUE;
 
}

posted on 2010-03-04 16:45 wilyquan 阅读(374) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
 
Copyright © wilyquan Powered by: 博客园 模板提供:沪江博客