ReadIEKey.cpp
上传用户:ayxnkj
上传日期:2022-06-19
资源大小:11910k
文件大小:8k
- #include "StdAfx.h"
- #include <UrlHist.h>
- #include "ReadIEKey.h"
- CReadIEKey::CReadIEKey(void)
- {
- }
- CReadIEKey::~CReadIEKey(void)
- {
- }
- int CReadIEKey::KeyOfYahoo(CString sWebTitle)
- {
- if(sWebTitle.Find(L"Yahoo!専嶕") == -1)
- {
- return 0;
- }else
- {
- m_KeyWord = sWebTitle.TrimLeft( L"Yahoo!専嶕 - " );
- return 1;
- }
- }
- int CReadIEKey::KeyOfGoogle(CString sWebTitle)
- {
- if(sWebTitle.Find(L"Google 専嶕") == -1)
- {
- return 0;
- }else
- {
- m_KeyWord = sWebTitle.TrimRight(L" - Google 専嶕");
- return 1;
- }
- }
- int CReadIEKey::KeyOfYahooBus(CString sWebTitle)
- {
- int PosKey1,PosKey2,Lenth;
- if(sWebTitle.Find(L"寢壥 - Yahoo!楬慄忣曬") == -1)
- {
- return 0;
- }else
- {
- sWebTitle = sWebTitle.TrimLeft( L"乽" );
- sWebTitle = sWebTitle.TrimRight( L"乿傊偺宱楬丄塣捓扵嶕寢壥 - Yahoo!楬慄忣曬" );
- Lenth = sWebTitle.GetLength();
- PosKey1 = sWebTitle.Find(L"乿");
- PosKey2 = sWebTitle.Find(L"乽");
- m_KeyBus.sKeyStartBus = sWebTitle.Left(PosKey1);
- m_KeyBus.sKeyEndBus = sWebTitle.Right(Lenth - PosKey2 - 1);
- return 1;
- }
- }
- void CReadIEKey::GetLastnKeyWord()
- {
- HRESULT hr;
- STATURL su;
- ULONG celt;
- IEnumSTATURL *pesu;
- IUrlHistoryStg2 *puhs;
- KEYINFO TempInfo;
- m_KeyNum = 0;
- hr = CoInitialize(NULL);
- hr = CoCreateInstance(CLSID_CUrlHistory,NULL,CLSCTX_INPROC_SERVER,IID_IUrlHistoryStg,(LPVOID*)&puhs);
-
- if(SUCCEEDED(hr))
- {
- hr = puhs->EnumUrls(&pesu);
- if(SUCCEEDED(hr))
- {
- while(SUCCEEDED(pesu->Next(1,&su,&celt))&&celt>0)
- {
- if(su.pwcsTitle)
- {
- if(KeyOfYahoo(su.pwcsTitle) ||
- KeyOfGoogle(su.pwcsTitle))
- {
- m_KeyInfo[m_KeyNum].MultiFind = FALSE;
- for(int i=0 ; i<m_KeyNum ; i++ )
- {
- if(lstrcmpi(m_KeyInfo[i].sKeyName,m_KeyWord) == 0)
- {
- m_KeyInfo[i].FindNum++;
- m_KeyInfo[m_KeyNum].MultiFind = TRUE;
- }
- }
- if(m_KeyInfo[m_KeyNum].MultiFind == FALSE)
- {
- m_KeyInfo[m_KeyNum].sKeyName = m_KeyWord;
- m_KeyInfo[m_KeyNum].VisitTime = su.ftLastUpdated;
- m_KeyInfo[m_KeyNum].FindNum = 1;
- m_KeyNum++;
- }
-
- }
- }
-
- }
- puhs->Release();
- }
- puhs->Release();
- }
- for(int j=0 ; j<m_KeyNum ; j++)
- {
- for(int k=0; k<m_KeyNum-j-1;k++)
- {
- if(CompareFileTime(&m_KeyInfo[k].VisitTime,&m_KeyInfo[k+1].VisitTime) < 0)
- {
- TempInfo = m_KeyInfo[k+1];
- m_KeyInfo[k+1] = m_KeyInfo[k];
- m_KeyInfo[k] = TempInfo;
- }
- }
- }
-
- }
- void CReadIEKey::GetMostnKeyWord()
- {
- int i,j,k;
- HRESULT hr;
- STATURL su;
- ULONG celt;
- IEnumSTATURL *pesu;
- IUrlHistoryStg2 *puhs;
- KEYINFO TempInfo;
-
- m_KeyNum = 0;
- hr = CoInitialize(NULL);
- hr = CoCreateInstance(CLSID_CUrlHistory,NULL,CLSCTX_INPROC_SERVER,IID_IUrlHistoryStg,(LPVOID*)&puhs);
-
- if(SUCCEEDED(hr))
- {
- hr = puhs->EnumUrls(&pesu);
- if(SUCCEEDED(hr))
- {
- while(SUCCEEDED(pesu->Next(1,&su,&celt))&&celt>0)
- {
- if(su.pwcsTitle)
- {
- if(KeyOfYahoo(su.pwcsTitle) ||
- KeyOfGoogle(su.pwcsTitle))
- {
- m_KeyInfo[m_KeyNum].MultiFind = FALSE;
- for(i=0 ; i<m_KeyNum ; i++ )
- {
- if(lstrcmpi(m_KeyInfo[i].sKeyName,m_KeyWord) == 0)
- {
- m_KeyInfo[i].FindNum++;
- m_KeyInfo[m_KeyNum].MultiFind = TRUE;
- }
- }
- if(m_KeyInfo[m_KeyNum].MultiFind == FALSE)
- {
- m_KeyInfo[m_KeyNum].sKeyName = m_KeyWord;
- m_KeyInfo[m_KeyNum].VisitTime = su.ftLastUpdated;
- m_KeyInfo[m_KeyNum].FindNum = 1;
- m_KeyNum++;
- }
-
- }
- }
-
- }
- puhs->Release();
- }
- puhs->Release();
- }
- for(j=0 ; j<m_KeyNum ; j++)
- {
- for(k=0; k<m_KeyNum-j-1;k++)
- {
- if(CompareFileTime(&m_KeyInfo[k].VisitTime,&m_KeyInfo[k+1].VisitTime) < 0)
- {
- TempInfo = m_KeyInfo[k+1];
- m_KeyInfo[k+1] = m_KeyInfo[k];
- m_KeyInfo[k] = TempInfo;
- }
- }
- }
- for(j=0 ; j<m_KeyNum ; j++)
- {
- for(k=0; k<m_KeyNum-j-1;k++)
- {
- if(m_KeyInfo[k].FindNum < m_KeyInfo[k+1].FindNum)
- {
- TempInfo = m_KeyInfo[k+1];
- m_KeyInfo[k+1] = m_KeyInfo[k];
- m_KeyInfo[k] = TempInfo;
- }
- }
- }
- }
- void CReadIEKey::GetLastnBus()
- {
- HRESULT hr;
- STATURL su;
- ULONG celt;
- IEnumSTATURL *pesu;
- IUrlHistoryStg2 *puhs;
- BUSKEYWORD TempInfo;
- m_KeyNum = 0;
- hr = CoInitialize(NULL);
- hr = CoCreateInstance(CLSID_CUrlHistory,NULL,CLSCTX_INPROC_SERVER,IID_IUrlHistoryStg,(LPVOID*)&puhs);
-
- if(SUCCEEDED(hr))
- {
- hr = puhs->EnumUrls(&pesu);
- if(SUCCEEDED(hr))
- {
- while(SUCCEEDED(pesu->Next(1,&su,&celt))&&celt>0)
- {
- if(su.pwcsTitle)
- {
- if(KeyOfYahooBus(su.pwcsTitle))
- {
- m_KeyBusInfo[m_KeyNum].MultiFind = FALSE;
- for(int i=0 ; i<m_KeyNum ; i++ )
- {
- if(lstrcmpi(m_KeyBusInfo[i].sKeyStartBus,m_KeyBus.sKeyStartBus) == 0
- &&lstrcmpi(m_KeyBusInfo[i].sKeyEndBus,m_KeyBus.sKeyEndBus) == 0)
- {
- m_KeyBusInfo[i].FindNum++;
- m_KeyBusInfo[m_KeyNum].MultiFind = TRUE;
- }
- }
- if(m_KeyBusInfo[m_KeyNum].MultiFind == FALSE)
- {
- m_KeyBusInfo[m_KeyNum].sKeyStartBus = m_KeyBus.sKeyStartBus;
- m_KeyBusInfo[m_KeyNum].sKeyEndBus = m_KeyBus.sKeyEndBus;
- m_KeyBusInfo[m_KeyNum].VisitTime = su.ftLastUpdated;
- m_KeyBusInfo[m_KeyNum].FindNum = 1;
- m_KeyNum++;
- }
-
- }
- }
-
- }
- puhs->Release();
- }
- puhs->Release();
- }
- for(int j=0 ; j<m_KeyNum ; j++)
- {
- for(int k=0; k<m_KeyNum-j-1;k++)
- {
- if(CompareFileTime(&m_KeyBusInfo[k].VisitTime,&m_KeyBusInfo[k+1].VisitTime) < 0)
- {
- TempInfo = m_KeyBusInfo[k+1];
- m_KeyBusInfo[k+1] = m_KeyBusInfo[k];
- m_KeyBusInfo[k] = TempInfo;
- }
- }
- }
-
- }
- void CReadIEKey::GetMostnBus()
- {
- HRESULT hr;
- STATURL su;
- ULONG celt;
- IEnumSTATURL *pesu;
- IUrlHistoryStg2 *puhs;
- BUSKEYWORD TempInfo;
- m_KeyNum = 0;
- hr = CoInitialize(NULL);
- hr = CoCreateInstance(CLSID_CUrlHistory,NULL,CLSCTX_INPROC_SERVER,IID_IUrlHistoryStg,(LPVOID*)&puhs);
-
- if(SUCCEEDED(hr))
- {
- hr = puhs->EnumUrls(&pesu);
- if(SUCCEEDED(hr))
- {
- while(SUCCEEDED(pesu->Next(1,&su,&celt))&&celt>0)
- {
- if(su.pwcsTitle)
- {
- if(KeyOfYahooBus(su.pwcsTitle))
- {
- m_KeyBusInfo[m_KeyNum].MultiFind = FALSE;
- for(int i=0 ; i<m_KeyNum ; i++ )
- {
- if(lstrcmpi(m_KeyBusInfo[i].sKeyStartBus,m_KeyBus.sKeyStartBus) == 0
- &&lstrcmpi(m_KeyBusInfo[i].sKeyEndBus,m_KeyBus.sKeyEndBus) == 0)
- {
- m_KeyBusInfo[i].FindNum++;
- m_KeyBusInfo[m_KeyNum].MultiFind = TRUE;
- }
- }
- if(m_KeyBusInfo[m_KeyNum].MultiFind == FALSE)
- {
- m_KeyBusInfo[m_KeyNum].sKeyStartBus = m_KeyBus.sKeyStartBus;
- m_KeyBusInfo[m_KeyNum].sKeyEndBus = m_KeyBus.sKeyEndBus;
- m_KeyBusInfo[m_KeyNum].VisitTime = su.ftLastUpdated;
- m_KeyBusInfo[m_KeyNum].FindNum = 1;
- m_KeyNum++;
- }
-
- }
- }
-
- }
- puhs->Release();
- }
- puhs->Release();
- }
- for(int j=0 ; j<m_KeyNum ; j++)
- {
- for(int k=0; k<m_KeyNum-j-1;k++)
- {
- if(CompareFileTime(&m_KeyBusInfo[k].VisitTime,&m_KeyBusInfo[k+1].VisitTime) < 0)
- {
- TempInfo = m_KeyBusInfo[k+1];
- m_KeyBusInfo[k+1] = m_KeyBusInfo[k];
- m_KeyBusInfo[k] = TempInfo;
- }
- }
- }
- for(int j=0 ; j<m_KeyNum ; j++)
- {
- for(int k=0; k<m_KeyNum-j-1;k++)
- {
- if(m_KeyBusInfo[k].FindNum < m_KeyBusInfo[k+1].FindNum)
- {
- TempInfo = m_KeyBusInfo[k+1];
- m_KeyBusInfo[k+1] = m_KeyBusInfo[k];
- m_KeyBusInfo[k] = TempInfo;
- }
- }
- }
- }