Exemple #1
0
	bool RegisterComDLL(HINSTANCE hin,LPCTSTR dll)
	{
		TCHAR curpath[MAX_PATH];
		GetModuleFileName( hin, curpath, MAX_PATH );
		PathRemoveFileSpec(curpath);
		ATL::CString file;
		file += "regsvr32 \"";
		file += curpath;
		file += "\\";
		file += dll;
		file += "\" /s";
		STARTUPINFO si={0};
		si.cb = sizeof(si);
		PROCESS_INFORMATION pi={0};
		if(!CreateProcess( NULL,(LPWSTR)file.GetString(),  NULL,NULL,FALSE,0, NULL,NULL,&si, &pi ))
		{
			DebugOutF(filelog::log_error,"CreateProcess failed with %d",GetLastError() );
			return false;
		}
		WaitForSingleObject(pi.hProcess,-1);
		DWORD exitcode = 0;
		GetExitCodeProcess(pi.hProcess,&exitcode);
		if(pi.hProcess)CloseHandle(pi.hProcess);
		if(pi.hThread)CloseHandle(pi.hThread);
		return exitcode == 0;
	}
Exemple #2
0
 ///process based init
 /// todo - destructor order(I am not sure if it is correct!!)
 bool PluginMng::InitPlugins(){
   if (plugins_.empty()){
     LoadPlugins();
     uuiterator vb=plugins_.begin(),ve=plugins_.end();
     for (uuiterator i=vb;i!=ve;++i){
       uuplugin* p= *i;
       CRegKey crk;
       long rk=crk.Open(HKEY_LOCAL_MACHINE, _6bees_const::kplugindisabled, KEY_READ|KEY_WRITE);
       if (rk==ERROR_SUCCESS){
         DWORD i=0;
         ATL::CString menuid;
         menuid.Format(_T("%d"),p->menuwID_);
         if (crk.QueryDWORDValue(menuid,i)==ERROR_SUCCESS){
           p->enabled_ = false;
         }
       }
       if (p->enabled_){
         p->init();
       }else{
         disabled_plugins_.push_back(p);
       }
     }
     fillpartswidth();
   }
   return true;
 }
int CSetProxServer::readInt(ATL::CString str)
{
	int nValue = 0;
// 	if (str.Compare(PROX_SERVER_TYPE_IE) == 0)
// 	{
// 		nValue = 1;
// 	}
	if (str.Compare(PROX_SERVER_TYPE_NONE) == 0)
	{
		nValue = 0;
	}
	else if (str.Compare(PROX_SERVER_TYPE_HTTP) == 0)
	{
		nValue = 1;
	}
	else if (str.Compare(PROX_SERVER_TYPE_SOCK) == 0)
	{
		nValue = 2;
	}
	else if (str.Compare(PROX_SERVER_VERIFY_NO) == 0)//验证过程
	{
		nValue = 0;
	}
	else if (str.Compare(PROX_SERVER_VERIFY_YES) == 0)
	{
		nValue = 1;
	}	
	else
	{
		nValue = -1;
	}
	return nValue;
}
Exemple #4
0
LRESULT CH_HBarWnd::OnHBarSearchPrev(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
  if(newpage){
    return 0;
  }
  CComBSTR search_words = NULL;
  m_BandEditCtrl.GetWindowText(&search_words);
  ATL::CString sw = search_words.m_str;
  if(sw.IsEmpty()){
    return 0;
  }
  newpage = FALSE;
  if(currentRange2==NULL){
    CComQIPtr<IHTMLBodyElement,&IID_IHTMLBodyElement> bodyElement(body);
    if(FAILED(bodyElement->createTextRange(&currentRange2)) && currentRange2==NULL){return 0;}
  }
  VARIANT_BOOL bSuccess;
  long t=0;
  if(wParam == HBAR_SEARCHPREVFAILED && lParam==HBAR_SEARCHPREVFAILED){//at the beginning
    CComQIPtr<IHTMLBodyElement,&IID_IHTMLBodyElement> bodyElement(body);
    if(FAILED(bodyElement->createTextRange(&currentRange2)) && currentRange2==NULL){return 0;}
  }else{
    currentRange2->setEndPoint(_T("EndToStart"),currentRange);
    currentRange2->moveEnd(_T("Character"),-1*search_words.Length(),&t);
  }
  DWORD flag = (m_case.GetCheck()==BST_UNCHECKED?0:FINDTEXT_MATCHCASE);
  if(currentRange2!=NULL && SUCCEEDED(currentRange2->findText(search_words,-1,flag,&bSuccess)) && bSuccess==VARIANT_TRUE){
    int a=0;
    if(FAILED(currentRange2->select())){a=1;}
    currentRange->setEndPoint(_T("StartToEnd"),currentRange2);
    if(a==1){::PostMessage(m_hWnd, WM_HBAR_SEARCH_PREV, 0, 0);}
  }else{
    ::PostMessage(m_hWnd, WM_HBAR_SEARCH_PREV, HBAR_SEARCHPREVFAILED, HBAR_SEARCHPREVFAILED);
  }
  return 0;
}
BOOL CSetProxServer::CheckIp( ATL::CString& str )//检查IP地址是否合法
{
	LPCWSTR   lpIpString = str.GetBuffer(-1);
	str.ReleaseBuffer(-1);
	int      nStrLen = 0; 
	int      nDotCount = 0; 

	nStrLen = wcslen(lpIpString); 
	if((nStrLen > 15) || (nStrLen < 7)) 
		return FALSE; 

	for(int i=0; i < nStrLen; ++i) 
	{ 
		if( lpIpString[i] == L'.' ) 
		{ 
			if( (lpIpString[i+1] == '.') || (i==0) || (i==nStrLen-1))
				return FALSE; 
			nDotCount++; 
			continue; 
		} 

		if( (lpIpString[i] < L'0') || (lpIpString[i] > L'9') )
			return   FALSE; 
	} 

	if( nDotCount == 3) 
	{ 
		if(inet_addr(CW2A(str.GetBuffer(-1))) != INADDR_NONE) 
		{ 
			return TRUE; 
		} 
	} 

	return FALSE;
}
Exemple #6
0
//////////////////////////////////////////////////////////////////////////
//时间与字符串互相转换函数
ATL::CString GlobeFuns::TimeToString(const CTime &t)
{
	ATL::CString strDateTime;
	strDateTime.Format("%d-%02d-%02d %02d:%02d:%02d", 
		t.GetYear(), t.GetMonth(), t.GetDay(),
		t.GetHour(), t.GetMinute(), t.GetSecond());
	return strDateTime;
}
ATL::CString GetStringValue(CRegKey& rk, const ATL::CString& valueName)
{
	ATL::CString result;
	DWORD dwLen = 1024;
	rk.QueryStringValue(valueName, result.GetBuffer(dwLen), &dwLen);
	result.ReleaseBuffer();
	return result;
}
void MainDialog::OnDropFiles(HDROP hdrop)
{
	ATL::CString path;
	UINT len = DragQueryFile(hdrop, 0, NULL, 0);
	char *pch = path.GetBufferSetLength(len);
	if(DragQueryFile(hdrop, 0, pch, len + 1)) {
		m_xml = pch;
		DoDataExchange(false, IDC_XML);
		EnableDlgItem(IDC_START);
	}
	DragFinish(hdrop);
}
Exemple #9
0
 PluginMng::~PluginMng(){
   for (int i=0;i<(int)plugins_.size();i++){
     uuplugin* uup = plugins_.at(i);
     CRegKey crk;
     long rk=crk.Open(HKEY_LOCAL_MACHINE, _6bees_const::kplugindisabled, KEY_READ|KEY_WRITE);
     if (rk==ERROR_SUCCESS){
       ATL::CString menuid;
       menuid.Format(_T("%d"),uup->menuwID_);
       if(uup->enabled_){
         crk.DeleteValue(menuid);
       }else{
         crk.SetDWORDValue(menuid,1);
       }
     }
   }
 }
Exemple #10
0
  UINT WINAPI alexa::thread_getalexa(LPVOID p){
    alexainfo* pas = static_cast<alexainfo*>(p);
    int alexarank = 0;
    std::wstring hostname(pas->hostname.c_str());
    if(url2alexa.find(hostname)==url2alexa.end()){
      alexarank = GetAlexaRank(pas->hostname.c_str());
      url2alexa[hostname] = alexarank;
    }else{
      alexarank = url2alexa[hostname];
    }

    ATL::CString stralexa;
    stralexa.Format(L"%d",alexarank);
    pas->alexaptr->tid2panetext_[pas->tid] = stralexa;
    if(IsWindow(pas->psb->m_hWnd))
      pas->psb->SetText(pas->paneid,stralexa);
    return 0;
  }
Exemple #11
0
HRESULT TimeToString( __time64_t nTime, ATL::CString& strTime )
{
	ATL::CTime time(nTime);
	strTime.Format( TEXT("%d %d %d %d:%d:%d"), 
		time.GetYear(), time.GetMonth(), 
		time.GetDay(), time.GetHour(), 
		time.GetMinute(),time.GetSecond());

	return S_OK;
}
Exemple #12
0
  bool alexa::OnNavigateComplete2(int paneid,const wchar_t* url){
    C6BeeMenuStatusBar* pSB = GetC6BeeMenuStatusBarPtr();
    if (pSB==NULL){
      return false;
    }
    ATL::CString myurl = url;
    if(myurl.Find(_T("http://"))!=0){
      return false;
    }
    int cut=myurl.Find(_T("/"),8);
    if (cut<0){return false;}
    myurl.Truncate(cut);

    alexa_info.paneid = paneid;
    alexa_info.hostname = myurl;
    alexa_info.psb = pSB;
    alexa_info.tid = GetCurrentThreadId();
    alexa_info.alexaptr = this;
    ::_beginthreadex(NULL,0,thread_getalexa,
      (LPVOID)&alexa::alexa_info,0,NULL);
    return true;
  }
Exemple #13
0
LRESULT CH_HBarWnd::OnCtlColorEdit(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
  HDC hdcEdit   = (HDC)  wParam; // handle to display context 
  HWND hwndEdit = (HWND) lParam; // handle to static control 
  if (hwndEdit==m_BandEditCtrl.m_hWnd)
  {
    CComBSTR search_words = NULL;
    m_BandEditCtrl.GetWindowText(&search_words);
    ATL::CString sw = search_words.m_str;
    if(sw.IsEmpty() && bkcolor!=kGreen){
      bkcolor = kGreen;
      m_hBrush = ::CreateSolidBrush(bkcolor);
      RECT rc;
      m_BandEditCtrl.GetClientRect(&rc);
      m_BandEditCtrl.InvalidateRect(&rc,TRUE);
    }
    if (m_hBrush == NULL)
      m_hBrush = ::CreateSolidBrush(bkcolor);
    SetBkColor(hdcEdit,bkcolor);
    SetTextColor(hdcEdit, RGB(0,20,245));
    return ((LRESULT) m_hBrush);
  }
  return 0;
}
LRESULT CSiteSelectedBoxWnd::OnClicked_BtnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	ATL::CString strName;
	m_ctrlSiteCombo.GetLBText(m_ctrlSiteCombo.GetCurSel(), strName);

	map<TSTLSTRING, TSTLSTRING>::iterator iterSite = m_SiteMap.find(strName.GetString());
	if(iterSite == m_SiteMap.end())
	{
		MessageBox(TEXT("您没有选择站点?"), TEXT("提示"), MB_OK|MB_ICONINFORMATION);
		bHandled = TRUE;
		return 0;
	}

	try
	{
		ConfigureManager::GetInstance().SetSettingValue(TEXT("sitename"), iterSite->second);
		ConfigureManager::GetInstance().Save();
	}
	catch(Exception& error)
	{
		MessageBox(error.GetMessage().c_str(), TEXT("错误"), MB_OK|MB_ICONERROR);
	}

	DestroyWindow();
	if(!OnSelected.m_EventList.empty())
	{
		Event< SiteSelected >::EventIterator iter;
		for( iter = OnSelected.m_EventList.begin();
			iter != OnSelected.m_EventList.end();
			++iter )
		{
			InvokeEvent(true, iterSite->second);
		}
	}
	bHandled = TRUE;
	return 0;
}
IUnknownPtr GenericCLRLoader::WSCoCreateDotNetInstancePtr(const CLSID& clsid)
{
	LPOLESTR szClsid;
	HRESULT hr = StringFromCLSID(clsid, &szClsid);
	if (FAILED(hr))
		throw _com_error(hr);
	ATL::CString sClsid = szClsid;
	CoTaskMemFree(szClsid);

	CRegKey rkCLSID;
	hr = rkCLSID.Open(HKEY_CLASSES_ROOT, L"CLSID\\" + sClsid + L"\\InprocServer32", KEY_READ);
	if (hr != ERROR_SUCCESS)
		throw _com_error(HRESULT_FROM_WIN32(hr));

	ATL::CString sAssembly = GetStringValue(rkCLSID, L"Assembly");
	ATL::CString sClass = GetStringValue(rkCLSID, L"Class");
	ATL::CString sCodeBase = GetStringValue(rkCLSID, L"CodeBase");

	if (sAssembly.GetLength() == 0 || sClass.GetLength() == 0 || sCodeBase.GetLength() == 0)
		throw _com_error(REGDB_E_CLASSNOTREG);

	ATL::CString dllPath;
	ATL::CString strFilePrefix(_T("file:///"));
	if (sCodeBase.Left(strFilePrefix.GetLength()).MakeLower() == strFilePrefix)
	{
		dllPath = sCodeBase.Mid(strFilePrefix.GetLength()); // discard 'file:///'
	}
	else
	{
		dllPath = sCodeBase;
	}

	IUnknownPtr result;

	hr = TheInstance()->CreateCOMObject(dllPath, sAssembly, sClass, &result);
	if (FAILED(hr))
		throw _com_error(hr);

	return result;

}
// an instance of the requested add-in in that AppDomain.
HRESULT GenericCLRLoader::CreateObject(const ATL::CString& sAssemblyFile, const ATL::CString& sAssemblyName, const ATL::CString& sTypeName, 
	mscorlib::_ObjectHandle** ppObject, const ATL::CString& sConfigFile, const ATL::CString& sDomainName, int LocaleID)
{
	HRESULT hr = E_FAIL;

	try
	{
		m_skipCleanup = true;


		// Ensure the common language runtime is running ...
		IfFailGo( LoadCLR(sAssemblyFile) );

		// In order to securely load an assembly, its fully qualified strong name
		// and not the filename must be used. To do that, the target AppDomain's 
		// base directory needs to point to the directory where the assembly is
		// residing. CreateLocalAppDomain() ensures that such AppDomain exists.
		//
		// VE3580 "Error:0x8000ffff is seen only on the first save to SharePoint. Windows XP SP3 with Office 2003"
		// If no config file is specified when creating the appdomain the first time a Uri object is created an exception is thrown,
		// Its trying to read a config file that is NULL. So specify a dummy file name to prevent this.
		IfFailGo( CreateLocalAppDomain(sDomainName, sConfigFile.IsEmpty() ? "app.config" : sConfigFile) );

		// Create an instance of the managed class
		if (LocaleID != -1)
			m_pLocalDomain->SetData(CComBSTR("LocaleID"), CComVariant(LocaleID));
		
		IfFailGo(m_pLocalDomain->CreateInstance(CComBSTR(sAssemblyName), CComBSTR(sTypeName), ppObject));
	}
	catch(...)
	{
		LOG_WS_INFO(_T("Unable to load clr, create app domain, run CLRPolicyReader"));
	}

Error:
	return hr;
}
Exemple #17
0
//----------------------------------------------        
//modified by robet.li
BOOL HasChineseChar(const ATL::CString &destStr)
{
	BOOL bHasChinsesChar = FALSE;
	int nLen = destStr.GetLength();
	unsigned char c1,c2;
	BOOL bFirstSpace = TRUE;

	for(int i=0; i<nLen; i++)
	{
		c1 = destStr[i];

		if((i+1) >= nLen)
		{
			if (bFirstSpace && (c1 == ' ' || c1 == '\t'))
			{
			}
			else
			{
				//strConv += destStr[i];
				bFirstSpace = FALSE;
			}
			break;
		}
		else
		{
			c2 = destStr[i+1];
			if(c1 == 163)  //ÅжÏÊÇ·ñΪȫ½Ç×Ö·û
			{
				//strConv += TCHAR(c2-128);
				i++;
				bFirstSpace = FALSE;
			}
			else if((int)c1 > 163) //ÅжÏÊÇ·ñΪÎÄ×Ö
			{
				//strConv += (TCHAR)c1;
				//strConv += (TCHAR)c2;
				i++;
				bFirstSpace = FALSE;
				bHasChinsesChar = TRUE;
				break;
			}
			else if((c1 == 161) && (c2 == 161)) //ȫΪ¿Õ¸ñ
			{
				i++;
			}
			else      //Èç¹ûÊÇ°ë½Ç×Ö·û
			{
				if (bFirstSpace && (c1 == ' ' || c1 == '\t'))
				{
				}
				else
				{
					//strConv += (TCHAR)c1;
					bFirstSpace = FALSE;
				}
			}//endi
		}
	}

	return bHasChinsesChar;
}
Exemple #18
0
void CSetProxServer::ReadSettingsAndSet(int nFlag = -1)
{
	int				nType;
	TCHAR			sUser[256] = {0};
	TCHAR			sPass[256] = {0};
	TCHAR			sHost[256] = {0};		
	int				nPort = 80;
	int				nValidate;	
	ATL::CString	strPort = L"";
	CIniFile iniFile(m_strFilePath);
	iniFile.GetIntValue(L"proxy",	L"type",		nType);

	if (nFlag == -1)//
	{
		if (nType == -1)//第一次使用的情况
		{
			nType = 1;
			m_bChanged = TRUE;
		}		
	}	
	else
	{
		nType = nFlag;
	}	
	m_ComBoHttp.SetCurSel(nType);
	
	iniFile.GetIntValue(L"proxy",	L"validate",	nValidate);
	if (nValidate == -1)
	{
		nValidate = 1;//默认情况下是需要验证的
	}
	iniFile.GetStrValue(L"proxy",	L"host",		sHost,	sizeof(sHost));
	iniFile.GetIntValue(L"proxy",	L"port",		nPort);			
	iniFile.GetStrValue(L"proxy",	L"user",		sUser,	sizeof(sUser));
	iniFile.GetStrValue(L"proxy",	L"password",	sPass,	sizeof(sPass));
	
	HWND hWndVerify   = ::GetDlgItem(GetViewHWND(), IDC_COMBO_PROX_SERVER_VERIFY);
	HWND hWndAddr     = ::GetDlgItem(GetViewHWND(), IDC_EDITBOX_PROX_SERVER_ADDR);
	HWND hWndPort     = ::GetDlgItem(GetViewHWND(), IDC_EDITBOX_PROX_SERVER_PORT);
	HWND hWndAccount  = ::GetDlgItem(GetViewHWND(), IDC_EDITBOX_PROX_SERVER_ACCOUNT);
	HWND hWndPass     = ::GetDlgItem(GetViewHWND(), IDC_EDITBOX_PROX_SERVER_PASS);
	if (nType == 0)//不使用的情况
 	{		
		::EnableWindow(hWndVerify,  FALSE);
		::EnableWindow(hWndAddr,	FALSE);
		::EnableWindow(hWndPort,	FALSE);
		::EnableWindow(hWndAccount, FALSE);
		::EnableWindow(hWndPass,	FALSE);
		ReSet();
	}
	else
	{		
		if (nPort == -1)
		{
			if (nType == 1)
				nPort = 80;
			else if (nType == 2)
				nPort = 1080;
		}
		strPort.Format(L"%d", nPort);
		::EnableWindow(hWndVerify,  TRUE);
		::EnableWindow(hWndAddr,	TRUE);
		::EnableWindow(hWndPort,	TRUE);
		::EnableWindow(hWndAccount, nValidate);
		::EnableWindow(hWndPass,	nValidate);
		if (nValidate <= 0)//不需要验证的时候
		{	
			memset(sUser, 0, sizeof(sUser));
			memset(sPass, 0, sizeof(sUser));
		}		
		m_ComBoVerify.SetCurSel(nValidate);
		m_wndEditAddr.SetWindowText(sHost);
		m_wndEditPort.SetWindowText(strPort);
		m_wndEditAccount.SetWindowText(sUser);
		m_wndEditPass.SetWindowText(sPass);
	}	
	return;
}
inline void MakeFilterString(ATL::CString& str)
{
	char *pch = str.GetBuffer();
	for(int i = 0; i < str.GetLength(); ++i)
		if(pch[i] == '|') pch[i] = '\0';
}
bool CFilterElementHide::IsMatchFilterElementHide(IHTMLElement* pEl) const
{
  HRESULT hr;

  if (!m_tagId.IsEmpty())
  {
    CComBSTR id;
    hr = pEl->get_id(&id);
    if ((hr != S_OK) || (id != CComBSTR(m_tagId)))
    {
      return false;
    }
  }
  if (!m_tagClassName.IsEmpty())
  {
    CComBSTR classNameBSTR;
    hr = pEl->get_className(&classNameBSTR);
    if (hr == S_OK)
    {
      CString className = classNameBSTR;
      int start = 0;
      CString specificClass;
      bool foundMatch = false;
      while ((specificClass = className.Tokenize(L" ", start)) != L"")
      {
        // TODO: Consider case of multiple classes. (m_tagClassName can be something like "foo.bar")
        if (specificClass == m_tagClassName)
        {
          foundMatch = true;
        }
      }
      if (!foundMatch)
      {
        return false;
      }
    }
  }
  if (!m_tag.IsEmpty())
  {
    CComBSTR tagName;
    hr = pEl->get_tagName(&tagName);
    tagName.ToLower();
    if ((hr != S_OK) || (tagName != CComBSTR(m_tag)))
    {
      return false;
    }
  }

  // Check attributes
  for (std::vector<CFilterElementHideAttrSelector>::const_iterator attrIt = m_attributeSelectors.begin(); 
        attrIt != m_attributeSelectors.end(); ++ attrIt)
  {
    ATL::CString value;
    bool attrFound = false;
    if (attrIt->m_type == CFilterElementHideAttrType::STYLE)
    {
      CComPtr<IHTMLStyle> pStyle;
      if (SUCCEEDED(pEl->get_style(&pStyle)) && pStyle)
      {
        CComBSTR bstrStyle;

        if (SUCCEEDED(pStyle->get_cssText(&bstrStyle)) && bstrStyle)
        {
          value = bstrStyle;
          value.MakeLower();
          attrFound = true;
        }
      }
    }
    else if (attrIt->m_type == CFilterElementHideAttrType::CLASS)
    {
      CComBSTR bstrClassNames;
      if (SUCCEEDED(pEl->get_className(&bstrClassNames)) && bstrClassNames)
      {
        value = bstrClassNames;
        attrFound = true;
      }
    }
    else if (attrIt->m_type == CFilterElementHideAttrType::ID)
    {
      CComBSTR bstrId;
      if (SUCCEEDED(pEl->get_id(&bstrId)) && bstrId)
      {
        value = bstrId;
        attrFound = true;
      }
    }
    else
    {
      auto attributeValue = GetHtmlElementAttribute(*pEl, attrIt->m_bstrAttr);
      if (attrFound = attributeValue.isAttributeFound)
      {
        value = ToCString(attributeValue.attributeValue);
      }
    }

    if (attrFound)
    {
      if (attrIt->m_pos == CFilterElementHideAttrPos::EXACT)
      {
        // TODO: IE rearranges the style attribute completely. Figure out if anything can be done about it.
        if (value != attrIt->m_value)
          return false;
      }
      else if (attrIt->m_pos == CFilterElementHideAttrPos::STARTING)
      {
        if (value.Left(attrIt->m_value.GetLength()) != attrIt->m_value)
          return false;
      }
      else if (attrIt->m_pos == CFilterElementHideAttrPos::ENDING)
      {
        if (value.Right(attrIt->m_value.GetLength()) != attrIt->m_value)
          return false;
      }
      else if (attrIt->m_pos == CFilterElementHideAttrPos::ANYWHERE)
      {
        if (value.Find(attrIt->m_value) < 0)
          return false;
      }
      else if (attrIt->m_value.IsEmpty())
      {
        return true;
      }
    }
    else
    {
      return false;
    }
  }

  if (m_predecessor)
  {
    CComPtr<IHTMLElement> pDomPredecessor;
    HRESULT hr = S_FALSE;
    switch (m_predecessor->m_type)
    {
    case ETraverserComplexType::TRAVERSER_TYPE_PARENT:
      hr = pEl->get_parentElement(&pDomPredecessor);
      break;
    case ETraverserComplexType::TRAVERSER_TYPE_IMMEDIATE:
      hr = S_FALSE;
      CComQIPtr<IHTMLDOMNode> pPrevSiblingNode = pEl;
      long type = 0;
      while (pPrevSiblingNode && type != 1)
      {
        IHTMLDOMNode* tmpNode;
        pPrevSiblingNode->get_previousSibling(&tmpNode);
        pPrevSiblingNode.Attach(tmpNode);
        if (pPrevSiblingNode)
        {
          hr = pPrevSiblingNode->get_nodeType(&type);
          if (hr != S_OK)
            pPrevSiblingNode.Release();
        }
      }

      if (pPrevSiblingNode)
        hr = pPrevSiblingNode.QueryInterface(&pDomPredecessor);
      else
        return false;
      break;
    }
    if (hr != S_OK)
      return false;
    return m_predecessor->IsMatchFilterElementHide(pDomPredecessor);
  }

  return true;
}
Exemple #21
0
BOOL CSetProxServer::doApplySetting()
{
	//写配置文件	
	CIniFile IniFile(m_strFilePath);
	ATL::CString strHttp	= L"";
	int			 nType;
	ATL::CString strVerify	= L"";
	int			 nVerify;
	ATL::CString strAddr	= L"";
	ATL::CString strPort	= L"";
	int			 nPort;
	ATL::CString strAccount = L"";
	ATL::CString strPass	= L"";
	HRESULT hr;
	EM_KXE_NETPROXY_TYPE emType;
	int nIndex = m_ComBoHttp.GetCurSel();
	if ( nIndex!= -1)
	{
		int n = m_ComBoHttp.GetLBTextLen( nIndex );
		m_ComBoHttp.GetLBText( nIndex, strHttp.GetBuffer(n) );
		strHttp.ReleaseBuffer();
	}
	nIndex = m_ComBoVerify.GetCurSel();
	if (nIndex != -1)
	{
		int n = m_ComBoVerify.GetLBTextLen( nIndex );
		m_ComBoVerify.GetLBText( nIndex, strVerify.GetBuffer(n) );
		strVerify.ReleaseBuffer();
	}
	//获得地址
	m_wndEditAddr.GetWindowText(strAddr);
	//ip地址过滤
	if ((strAddr == L"" || !CheckIp(strAddr)) && m_ComBoHttp.GetCurSel() != 0)
	{
		CBkSafeMsgBox2::ShowMultLine( L"IP地址为空或者不合法,请您重新输入!", L"金山卫士",  MB_OK|MB_ICONWARNING);
		return FALSE;
	}
	
	m_wndEditPort.GetWindowText(strPort);
	//port检测
	if (strPort == L"" && m_ComBoHttp.GetCurSel() != 0)
	{
		CBkSafeMsgBox2::ShowMultLine( L"端口设置不能为空,请您重新输入!", L"金山卫士",  MB_OK|MB_ICONWARNING);
		return FALSE;
	}
	m_wndEditAccount.GetWindowText(strAccount);
	m_wndEditPass.GetWindowText(strPass);	
	nType   = readInt(strHttp);
	nVerify = readInt(strVerify);
	if (strPort == L"")
		nPort = -1;
	else
		nPort = _ttoi(strPort);
	//判断验证情况下  用户名和密码是否为空
	if (nVerify == 1)//需要验证的情况
	{
		if (strAccount == L"" || strPass == L"")
		{
			CBkSafeMsgBox2::ShowMultLine( L"用户名或者密码不能为空,请您重新输入!", L"金山卫士",  MB_OK|MB_ICONWARNING);
			return FALSE;
		}
	}
	//写配置
	if (CBkSafeMsgBox2::ShowMultLine( L"您确定要对您刚修改的配置进行保存吗?", L"金山卫士",  MB_OKCANCEL|MB_ICONWARNING) == IDOK)
	{
		//向后台进行设置
		if (nType == 0)
			emType = EM_KXE_NETPROXY_TYPE_NOPROXY;
		if (nType == 1)
			emType = EM_KXE_NETPROXY_TYPE_HTTP;
		else if (nType == 2)
			emType = EM_KXE_NETPROXY_TYPE_SOCKET5;

		std::wstring sHost(strAddr);
		std::wstring sUser(strAccount);
		std::wstring sPass(strPass);
		KXE_CLOUD_PROXY_INFO ProxInfo;
		ProxInfo.emProxyType = emType;
		ProxInfo.strProxyHost = sHost;
		ProxInfo.dwProxyPort = nPort;
		ProxInfo.strProxyUsername = sUser;
		ProxInfo.strProxyPassword = sPass;
		hr = m_kwsScanner.SetCloudProxyInfo(ProxInfo);
		if (hr != 0)//设置失败
		{
			CBkSafeMsgBox2::ShowMultLine( L"保存失败,请您重新设置?", L"金山卫士",  MB_OKCANCEL|MB_ICONWARNING);
			return FALSE;  
		}
		//后台设置成功后  再写配置文件
		IniFile.SetIntValue(TEXT("proxy"),TEXT("type"),		nType);
		IniFile.SetStrValue(TEXT("proxy"),TEXT("host"),		strAddr);
		IniFile.SetIntValue(TEXT("proxy"),TEXT("port"),		nPort);
		IniFile.SetIntValue(TEXT("proxy"),TEXT("validate"), nVerify);
		IniFile.SetStrValue(TEXT("proxy"),TEXT("user"),		strAccount);
		IniFile.SetStrValue(TEXT("proxy"),TEXT("password"), strPass);
		NotifyDownModuleProxyChange( nType, strAddr, nPort, (BOOL)nVerify, strAccount, strPass );
		GetParent().PostMessage( MSG_PROXY_CHANGE, NULL, NULL );
	}
	else
	{
		return FALSE;
	}
	
	return TRUE;
}