#include "wabobject.h" enum { ieidPR_DISPLAY_NAME = 0, ieidPR_ENTRYID, ieidPR_OBJECT_TYPE, ieidPR_WAB_CONF_SERVERS, ieidMax }; static const SizedSPropTagArray(ieidMax, ptaEid)= { ieidMax, { PR_DISPLAY_NAME, PR_ENTRYID, PR_OBJECT_TYPE, 0x8000101e, } }; enum { iemailPR_DISPLAY_NAME = 0, iemailPR_ENTRYID, iemailPR_EMAIL_ADDRESS, iemailPR_OBJECT_TYPE, iemailMax }; static const SizedSPropTagArray(iemailMax, ptaEmail)= { iemailMax, { PR_DISPLAY_NAME, PR_ENTRYID, PR_EMAIL_ADDRESS, PR_OBJECT_TYPE } }; enum { iphonePR_DISPLAY_NAME = 0, iphonePR_BUSINESS_TELEPHONE_NUMBER, iphonePR_HOME_TELEPHONE_NUMBER, iphonePR_ENTRYID, iphonePR_OBJECT_TYPE, iphoneMax }; static const SizedSPropTagArray(iphoneMax, ptaPhone)= { iphoneMax, { PR_DISPLAY_NAME, PR_BUSINESS_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_ENTRYID, PR_OBJECT_TYPE } }; enum { ibdayPR_BIRTHDAY=0, ibdayPR_DISPLAY_NAME, ibdayPR_ENTRYID, ibdayPR_OBJECT_TYPE, ibdayMax }; static const SizedSPropTagArray(ibdayMax, ptaBday)= { ibdayMax, { PR_BIRTHDAY, PR_DISPLAY_NAME, PR_ENTRYID, PR_OBJECT_TYPE } }; /*********************************************************************************************************/ ULONG ulProps[] = { PR_DISPLAY_NAME, PR_HOME_TELEPHONE_NUMBER, PR_HOME_FAX_NUMBER, PR_CELLULAR_TELEPHONE_NUMBER, PR_BUSINESS_TELEPHONE_NUMBER, PR_BUSINESS_FAX_NUMBER, PR_PAGER_TELEPHONE_NUMBER, PR_HOME_ADDRESS_STREET, PR_HOME_ADDRESS_CITY, PR_HOME_ADDRESS_STATE_OR_PROVINCE, PR_HOME_ADDRESS_POSTAL_CODE, PR_HOME_ADDRESS_COUNTRY, PR_DEPARTMENT_NAME, PR_COMPANY_NAME, PR_OFFICE_LOCATION, PR_BUSINESS_ADDRESS_STREET, PR_BUSINESS_ADDRESS_CITY, PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE, PR_BUSINESS_ADDRESS_POSTAL_CODE, PR_BUSINESS_ADDRESS_COUNTRY, PR_PERSONAL_HOME_PAGE, PR_BUSINESS_HOME_PAGE, PR_COMMENT, }; #define ulPropsMax 23 enum _Parts { pMain=0, pEmail, pPhone, pHome, pBusiness, pURLS, pNotes, pEnd, pPartsMax }; TCHAR szEmailPageHeader[] = "WAB Email Address List
"; TCHAR szEmailPageEnd[] = "
Email Addresses
 
"; LPTSTR szEmailItem[] = { "
  
%1%2
  
", "
  
%1%2
  
" }; TCHAR szPhonePageHeader[] = "WAB Phone List
Phone List
 
"; TCHAR szPhonePageEnd[] = "
 
"; LPTSTR szPhoneItem[] = { "  %1
Work:%2
Home:%3
  ", "  %1
Work:%2
Home:%3
  ", }; TCHAR szDetailsPageHeader[] = ""; TCHAR szDetailsPageMain[] = "%1
"; TCHAR szURLS[] = ""; TCHAR szNotes[] = "
%1
"; TCHAR szEmailAddressesStart[] = ""; TCHAR szPhoneNumbers[] = ""; TCHAR szHomeAddress[] = "
E-mail Addresses:
"; TCHAR szEmailAddressesMiddle[] = ""; TCHAR szEmailAddressesEnd[] = "
%1
Phone Numbers:
Home:%2
Home Fax:%3
Cellular:%4
Business:%5
Business-Fax:%6
Pager:%7
 
"; TCHAR szBusinessAddress[] = "
Home Address:
%8
%9 %10 %11
%12
Business Address:
%13
%14
%15
%16
%17 %18 %19
%20
  • Personal Home Page: %21
  • Business Web Page: %22
Notes: %23
"; TCHAR szDetailsPageEnd[] = ""; TCHAR szBdayHeader[] = "Birthdays
Birthdays
"; TCHAR szBdayEnd[] = "
 
"; TCHAR szBdaySingleItem[] = " 

%1

"; LPTSTR szBdayMonthItemStart[] = { "

%1

", ""; const LPTSTR szMonth[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; /*********************************************************************************************************/ // contructor CWAB::CWAB() { // Here we load the WAB Object and initialize it m_bInitialized = FALSE; { TCHAR szWABDllPath[MAX_PATH]; DWORD dwType = 0; ULONG cbData = sizeof(szWABDllPath); HKEY hKey = NULL; *szWABDllPath = '\0'; if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, WAB_DLL_PATH_KEY, 0, KEY_READ, &hKey)) RegQueryValueEx( hKey, "", NULL, &dwType, (LPBYTE) szWABDllPath, &cbData); if(hKey) RegCloseKey(hKey); m_hinstWAB = LoadLibrary( (lstrlen(szWABDllPath)) ? szWABDllPath : WAB_DLL_NAME ); } if(m_hinstWAB) m_lpfnWABOpen = (LPWABOPEN) GetProcAddress(m_hinstWAB, "WABOpen"); if(m_lpfnWABOpen) { HRESULT hr = E_FAIL; hr = m_lpfnWABOpen(&m_lpAdrBook,&m_lpWABObject,NULL,0); if(!hr) m_bInitialized = TRUE; } } CWAB::~CWAB() { if(m_bInitialized) { if(m_lpAdrBook) m_lpAdrBook->Release(); if(m_lpWABObject) m_lpWABObject->Release(); if(m_hinstWAB) FreeLibrary(m_hinstWAB); } } void CWAB::ClearWABLVContents(CListCtrl * pListView) { int i; int nCount = pListView->GetItemCount(); if(nCount<=0) return; for(i=0;iGetItem(&lvi); if(lvi.lParam) { LPSBinary lpSB = (LPSBinary) lvi.lParam; m_lpWABObject->FreeBuffer(lpSB); } } pListView->DeleteAllItems(); } HRESULT CWAB::LoadWABContents(CListCtrl * pListView) { ULONG ulObjType = 0; LPMAPITABLE lpAB = NULL; LPTSTR * lppszArray=NULL; ULONG cRows = 0; LPSRowSet lpRow = NULL; LPSRowSet lpRowAB = NULL; LPABCONT lpContainer = NULL; HRESULT hr = E_FAIL; ULONG lpcbEID; LPENTRYID lpEID = NULL; hr = m_lpAdrBook->GetPAB( &lpcbEID, &lpEID); ulObjType = 0; hr = m_lpAdrBook->OpenEntry(lpcbEID, (LPENTRYID)lpEID, NULL, 0, &ulObjType, (LPUNKNOWN *)&lpContainer); m_lpWABObject->FreeBuffer(lpEID); lpEID = NULL; hr = lpContainer->GetContentsTable( 0, &lpAB); if ( SUCCEEDED(hr) ) hr =lpAB->SetColumns( (LPSPropTagArray)&ptaEid, 0 ); if ( SUCCEEDED(hr) ) hr = lpAB->SeekRow( BOOKMARK_BEGINNING, 0, NULL ); int cNumRows = 0; int nRows=0; do { if ( SUCCEEDED(hr) ) hr = lpAB->QueryRows(1, 0, &lpRowAB); if(lpRowAB) { cNumRows = lpRowAB->cRows; if ( SUCCEEDED(hr) && cNumRows) { LPTSTR lpsz = lpRowAB->aRow[0].lpProps[ieidPR_DISPLAY_NAME].Value.lpszA; LPENTRYID lpEID = (LPENTRYID) lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.lpb; ULONG cbEID = lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.cb; if(lpRowAB->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.l == MAPI_MAILUSER) { LPSBinary lpSB = NULL; m_lpWABObject->AllocateBuffer(sizeof(SBinary), (LPVOID *) &lpSB); if(lpSB) { m_lpWABObject->AllocateMore(cbEID, lpSB, (LPVOID *) &(lpSB->lpb)); if(!lpSB->lpb) { m_lpWABObject->FreeBuffer(lpSB); continue; } CopyMemory(lpSB->lpb, lpEID, cbEID); lpSB->cb = cbEID; LV_ITEM lvi = {0}; lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iItem = pListView->GetItemCount(); lvi.iSubItem = 0; lvi.pszText = lpsz; lvi.lParam = (LPARAM) lpSB; // Now add this item to the list view pListView->InsertItem(&lvi); } } } FreeProws(lpRowAB ); } }while ( SUCCEEDED(hr) && cNumRows && lpRowAB) ; if ( lpContainer ) lpContainer->Release(); if ( lpAB ) lpAB->Release(); return hr; } BOOL CWAB::CreatePhoneListFileFromWAB(LPTSTR szFileName) { BOOL bRet = FALSE; ULONG ulObjType = 0; LPMAPITABLE lpAB = NULL; LPTSTR * lppszArray=NULL; ULONG cRows = 0; LPSRowSet lpRow = NULL; LPSRowSet lpRowAB = NULL; LPABCONT lpContainer = NULL; HRESULT hr = E_FAIL; ULONG lpcbEID; LPENTRYID lpEID = NULL; TCHAR szDir[MAX_PATH]; GetTempPath(MAX_PATH, szDir); lstrcpy(szFileName, szDir); lstrcat(szFileName, "temp.htm"); hr = m_lpAdrBook->GetPAB( &lpcbEID, &lpEID); ulObjType = 0; hr = m_lpAdrBook->OpenEntry(lpcbEID, (LPENTRYID)lpEID, NULL, 0, &ulObjType, (LPUNKNOWN *)&lpContainer); m_lpWABObject->FreeBuffer(lpEID); lpEID = NULL; hr = lpContainer->GetContentsTable( 0, &lpAB); if ( SUCCEEDED(hr) ) hr =lpAB->SetColumns( (LPSPropTagArray)&ptaPhone, 0 ); if ( SUCCEEDED(hr) ) hr = lpAB->SeekRow( BOOKMARK_BEGINNING, 0, NULL ); int cNumRows = 0; int nRows=0; HANDLE hFile = NULL; DWORD dw; hFile = CreateFile( szFileName, GENERIC_WRITE, 0, // sharing NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) szPhonePageHeader, (DWORD) lstrlen(szPhonePageHeader), &dw, NULL); } int nType = 0; do { if ( SUCCEEDED(hr) ) hr = lpAB->QueryRows(1, 0, &lpRowAB); if(lpRowAB) { cNumRows = lpRowAB->cRows; LPTSTR sz[iphoneMax]; if ( SUCCEEDED(hr) && cNumRows) { int i; for(i=0;iaRow[0].lpProps[i].Value.lpszA; if(!sz[i] || !lstrlen(sz[i])) sz[i] = TEXT(" "); } if(lpRowAB->aRow[0].lpProps[iphonePR_OBJECT_TYPE].Value.l == MAPI_MAILUSER) { LPTSTR lpPhoneItem =NULL; FormatMessage( FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_ALLOCATE_BUFFER, szPhoneItem[nType], 0, 0, //ignored (LPTSTR) &lpPhoneItem, 0, (va_list *)sz); nType = 1- nType; if(lpPhoneItem) { if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) lpPhoneItem, (DWORD) lstrlen(lpPhoneItem), &dw, NULL); } LocalFree(lpPhoneItem); } } } FreeProws(lpRowAB ); } }while ( SUCCEEDED(hr) && cNumRows && lpRowAB) ; if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) szPhonePageEnd, (DWORD) lstrlen(szPhonePageEnd), &dw, NULL); CloseHandle(hFile); } if ( lpContainer ) lpContainer->Release(); if ( lpAB ) lpAB->Release(); return bRet; } BOOL CWAB::CreateEmailListFileFromWAB(LPTSTR szFileName) { BOOL bRet = FALSE; ULONG ulObjType = 0; LPMAPITABLE lpAB = NULL; LPTSTR * lppszArray=NULL; ULONG cRows = 0; LPSRowSet lpRow = NULL; LPSRowSet lpRowAB = NULL; LPABCONT lpContainer = NULL; HRESULT hr = E_FAIL; ULONG lpcbEID; LPENTRYID lpEID = NULL; TCHAR szDir[MAX_PATH]; GetTempPath(MAX_PATH, szDir); lstrcpy(szFileName, szDir); lstrcat(szFileName, "temp.htm"); hr = m_lpAdrBook->GetPAB( &lpcbEID, &lpEID); ulObjType = 0; hr = m_lpAdrBook->OpenEntry(lpcbEID, (LPENTRYID)lpEID, NULL, 0, &ulObjType, (LPUNKNOWN *)&lpContainer); m_lpWABObject->FreeBuffer(lpEID); lpEID = NULL; hr = lpContainer->GetContentsTable( 0, &lpAB); if ( SUCCEEDED(hr) ) hr =lpAB->SetColumns( (LPSPropTagArray)&ptaEmail, 0 ); if ( SUCCEEDED(hr) ) hr = lpAB->SeekRow( BOOKMARK_BEGINNING, 0, NULL ); int cNumRows = 0; int nRows=0; HANDLE hFile = NULL; DWORD dw; hFile = CreateFile( szFileName, GENERIC_WRITE, 0, // sharing NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) szEmailPageHeader, (DWORD) lstrlen(szEmailPageHeader), &dw, NULL); } int nType = 0; do { if ( SUCCEEDED(hr) ) hr = lpAB->QueryRows(1, 0, &lpRowAB); if(lpRowAB) { cNumRows = lpRowAB->cRows; LPTSTR sz[2]; if ( SUCCEEDED(hr) && cNumRows) { sz[0] = lpRowAB->aRow[0].lpProps[iemailPR_DISPLAY_NAME].Value.lpszA; sz[1] = lpRowAB->aRow[0].lpProps[iemailPR_EMAIL_ADDRESS].Value.lpszA; if(!sz[1] || !lstrlen(sz[1])) sz[1] = "No E-mail"; if(lpRowAB->aRow[0].lpProps[iemailPR_OBJECT_TYPE].Value.l == MAPI_MAILUSER) { LPTSTR lpEmailItem =NULL; FormatMessage( FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_ALLOCATE_BUFFER, szEmailItem[nType], 0, 0, //ignored (LPTSTR) &lpEmailItem, 0, (va_list *)sz); nType = 1- nType; if(lpEmailItem) { if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) lpEmailItem, (DWORD) lstrlen(lpEmailItem), &dw, NULL); } LocalFree(lpEmailItem); } } } FreeProws(lpRowAB ); } }while ( SUCCEEDED(hr) && cNumRows && lpRowAB) ; if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) szEmailPageEnd, (DWORD) lstrlen(szEmailPageEnd), &dw, NULL); CloseHandle(hFile); } if ( lpContainer ) lpContainer->Release(); if ( lpAB ) lpAB->Release(); return bRet; } BOOL CWAB::CreateBirthdayFileFromWAB(LPTSTR szFileName) { BOOL bRet = FALSE; ULONG ulObjType = 0; LPMAPITABLE lpAB = NULL; LPTSTR * lppszArray=NULL; ULONG cRows = 0; LPSRowSet lpRow = NULL; LPSRowSet lpRowAB = NULL; LPABCONT lpContainer = NULL; HRESULT hr = E_FAIL; ULONG lpcbEID; LPENTRYID lpEID = NULL; TCHAR szDir[MAX_PATH]; GetTempPath(MAX_PATH, szDir); lstrcpy(szFileName, szDir); lstrcat(szFileName, "temp.htm"); hr = m_lpAdrBook->GetPAB( &lpcbEID, &lpEID); ulObjType = 0; hr = m_lpAdrBook->OpenEntry(lpcbEID, (LPENTRYID)lpEID, NULL, 0, &ulObjType, (LPUNKNOWN *)&lpContainer); m_lpWABObject->FreeBuffer(lpEID); lpEID = NULL; hr = lpContainer->GetContentsTable( 0, &lpAB); if ( SUCCEEDED(hr) ) hr =lpAB->SetColumns( (LPSPropTagArray)&ptaBday, 0 ); int cNumRows = 0; int nRows=0; HANDLE hFile = NULL; DWORD dw; hFile = CreateFile( szFileName, GENERIC_WRITE, 0, // sharing NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) szBdayHeader, (DWORD) lstrlen(szBdayHeader), &dw, NULL); } int nType = 0; int LastMonth = 0; BOOL bMonthSet = FALSE; for(LastMonth=1;LastMonth<=12;LastMonth++) { bMonthSet = FALSE; if ( SUCCEEDED(hr) ) hr = lpAB->SeekRow( BOOKMARK_BEGINNING, 0, NULL ); do { if ( SUCCEEDED(hr) ) hr = lpAB->QueryRows(1, 0, &lpRowAB); if(lpRowAB) { cNumRows = lpRowAB->cRows; if ( SUCCEEDED(hr) && cNumRows) { if( lpRowAB->aRow[0].lpProps[ibdayPR_BIRTHDAY].ulPropTag == PR_BIRTHDAY && lpRowAB->aRow[0].lpProps[ibdayPR_OBJECT_TYPE].Value.l == MAPI_MAILUSER) { FILETIME ft = lpRowAB->aRow[0].lpProps[ibdayPR_BIRTHDAY].Value.ft; SYSTEMTIME st; FileTimeToSystemTime(&ft, &st); if(st.wMonth == LastMonth) { if(bMonthSet == FALSE) { nType = 1- nType; LPTSTR lpMonthItem =NULL; FormatMessage( FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_ALLOCATE_BUFFER, szBdayMonthItemStart[nType], 0, 0, //ignored (LPTSTR) &lpMonthItem, 0, (va_list *)&szMonth[LastMonth-1]); if(lpMonthItem) { if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) lpMonthItem, (DWORD) lstrlen(lpMonthItem), &dw, NULL); } LocalFree(lpMonthItem); } bMonthSet = TRUE; } LPTSTR lpBdayItem = NULL; LPTSTR sz[2]; TCHAR szDate[256]; wsprintf(szDate,"%d",st.wDay); sz[0] = szDate; sz[1] = lpRowAB->aRow[0].lpProps[ibdayPR_DISPLAY_NAME].Value.LPSZ; FormatMessage( FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_ALLOCATE_BUFFER, szBdaySingleItem, 0, 0, //ignored (LPTSTR) &lpBdayItem, 0, (va_list *)sz); if(lpBdayItem) { if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) lpBdayItem, (DWORD) lstrlen(lpBdayItem), &dw, NULL); } LocalFree(lpBdayItem); } } } } FreeProws(lpRowAB ); } }while ( SUCCEEDED(hr) && cNumRows && lpRowAB) ; if(bMonthSet) { if(hFile != INVALID_HANDLE_VALUE) { WriteFile( hFile, (LPCVOID) szBdayMonthItemEnd, (DWORD) lstrlen(szBdayMonthItemEnd), &dw, NULL); } } }//for if(hFile != INVALID_HANDLE_VALUE) { if(LastMonth > 0) { WriteFile( hFile, (LPCVOID) szBdayMonthItemEnd, (DWORD) lstrlen(szBdayMonthItemEnd), &dw, NULL); } WriteFile( hFile, (LPCVOID) szBdayEnd, (DWORD) lstrlen(szBdayEnd), &dw, NULL); CloseHandle(hFile); } if ( lpContainer ) lpContainer->Release(); if ( lpAB ) lpAB->Release(); return bRet; } BOOL CWAB::CreateDetailsFileFromWAB(CListCtrl * pListView, LPTSTR szFileName) { BOOL bRet = FALSE; TCHAR szDir[MAX_PATH]; LV_ITEM lvi = {0}; LPMAILUSER lpMailUser = NULL; ULONG ulcProps; LPSPropValue lpPropArray = NULL; if(!szFileName) goto out; *szFileName = '\0'; if(!m_bDetailsOn) // This is not a details view goto out; // Get the Selected Item from the listview lvi.mask = LVIF_PARAM; lvi.iItem = pListView->GetNextItem(-1, LVNI_SELECTED); if(lvi.iItem == -1) goto out; lvi.iSubItem = 0; GetTempPath(MAX_PATH, szDir); lstrcpy(szFileName, szDir); lstrcat(szFileName, "temp.htm"); pListView->GetItem(&lvi); if(lvi.lParam) { LPSBinary lpSB = (LPSBinary) lvi.lParam; ULONG ulObjType; HRESULT hr = E_FAIL; hr = m_lpAdrBook->OpenEntry(lpSB->cb, (LPENTRYID) lpSB->lpb, NULL, // interface 0, // flags &ulObjType, (LPUNKNOWN *)&lpMailUser); if(hr || !lpMailUser) goto out; lpMailUser->GetProps(NULL, 0, &ulcProps, &lpPropArray); if(lpPropArray) { LPTSTR lpsz[ulPropsMax]; LPTSTR szEmpty = ""; ULONG i,j,nEmail = -1; for(i=0;i10) nCount = 10; { int i, nLen = 0; for(i=0;iFreeBuffer(lpPropArray); if(lpMailUser) lpMailUser->Release(); return bRet; } void CWAB::FreeProws(LPSRowSet prows) { ULONG irow; if (!prows) return; for (irow = 0; irow < prows->cRows; ++irow) m_lpWABObject->FreeBuffer(prows->aRow[irow].lpProps); m_lpWABObject->FreeBuffer(prows); } void CWAB::SetDetailsOn(BOOL bOn) { m_bDetailsOn = bOn; } void CWAB::ShowSelectedItemDetails(HWND hWndParent, CListCtrl * pListView) { HRESULT hr = S_OK; LV_ITEM lvi = {0}; // Get the Selected Item from the listview lvi.mask = LVIF_PARAM; lvi.iSubItem = 0; lvi.iItem = pListView->GetNextItem(-1, LVNI_SELECTED); if(lvi.iItem == -1) return; pListView->GetItem(&lvi); if(lvi.lParam) { HWND hWnd = NULL; LPSBinary lpSB = (LPSBinary) lvi.lParam; hr = m_lpAdrBook->Details( (LPULONG) &hWnd, // ulUIParam NULL, NULL, lpSB->cb, (LPENTRYID) lpSB->lpb, NULL, NULL, NULL, 0); if(hr) { TCHAR sz[MAX_PATH]; wsprintf(sz, "Error: %x GetLastError: %d\n",hr, GetLastError()); OutputDebugString(sz); } } return; } BOOL CWAB::GetSelectedItemBirthday(CListCtrl * pListView, SYSTEMTIME * lpst) { BOOL bRet = FALSE; LV_ITEM lvi = {0}; // Get the Selected Item from the listview lvi.mask = LVIF_PARAM; lvi.iSubItem = 0; lvi.iItem = pListView->GetNextItem(-1, LVNI_SELECTED); if(lvi.iItem == -1) goto out; pListView->GetItem(&lvi); if(lvi.lParam) { LPMAILUSER lpMailUser = NULL; LPSBinary lpSB = (LPSBinary) lvi.lParam; ULONG ulObjType = 0; m_lpAdrBook->OpenEntry(lpSB->cb, (LPENTRYID) lpSB->lpb, NULL, // interface 0, // flags &ulObjType, (LPUNKNOWN *)&lpMailUser); if(lpMailUser) { ULONG cProps; LPSPropValue lpPropArray = NULL; SizedSPropTagArray(1, ptaBday) = { 1, { PR_BIRTHDAY } }; lpMailUser->GetProps((LPSPropTagArray) &ptaBday, 0, &cProps, &lpPropArray); if(lpPropArray) { if(lpPropArray[0].ulPropTag == PR_BIRTHDAY) { FILETIME ft = lpPropArray[0].Value.ft; if(FileTimeToSystemTime(&ft, lpst)) { bRet = TRUE; } } m_lpWABObject->FreeBuffer(lpPropArray); } lpMailUser->Release(); } } out: return bRet; } void CWAB::SetSelectedItemBirthday(CListCtrl * pListView, SYSTEMTIME st) { LV_ITEM lvi = {0}; // Get the Selected Item from the listview lvi.mask = LVIF_PARAM; lvi.iSubItem = 0; lvi.iItem = pListView->GetNextItem(-1, LVNI_SELECTED); if(lvi.iItem == -1) goto out; pListView->GetItem(&lvi); if(lvi.lParam) { LPMAILUSER lpMailUser = NULL; LPSBinary lpSB = (LPSBinary) lvi.lParam; ULONG ulObjType = 0; m_lpAdrBook->OpenEntry(lpSB->cb, (LPENTRYID) lpSB->lpb, NULL, // interface MAPI_MODIFY, // flags &ulObjType, (LPUNKNOWN *)&lpMailUser); if(lpMailUser) { ULONG cProps; SPropValue PropArray = {0}; cProps = 1; PropArray.ulPropTag = PR_BIRTHDAY; FILETIME ft; if(SystemTimeToFileTime(&st, &ft)) { PropArray.Value.ft = ft; if(S_OK == lpMailUser->SetProps(cProps, &PropArray, NULL)) { lpMailUser->SaveChanges(KEEP_OPEN_READWRITE); } } lpMailUser->Release(); } } out: return; }

%1

", }; TCHAR szBdayMonthItemEnd[]= "