Ejemplo n.º 1
0
int GetAppLanguage(IVApplicationPtr app)
{
	long app_language = 0;
	if (FAILED(app->get_Language(&app_language)))
		return DEFAULT_LANGUAGE;

	CComVariant v_disp_language_settings;
	CComDispatchDriver disp = app;
	if (SUCCEEDED(disp.GetPropertyByName(L"LanguageSettings", &v_disp_language_settings)))
	{
		Office::LanguageSettingsPtr language_settings;
		if (SUCCEEDED(V_DISPATCH(&v_disp_language_settings)->QueryInterface(__uuidof(Office::LanguageSettings), (void**)&language_settings)))
		{
			int ui_language = app_language;
			if (SUCCEEDED(language_settings->get_LanguageID(Office::msoLanguageIDUI, &ui_language)))
				app_language = ui_language;
		}
	}

	switch (app_language)
	{
	case 1033:
	case 1031:
	case 1049:
		return app_language;
	}

	return DEFAULT_LANGUAGE;
}
LRESULT CIncrementSystemBFDlg::OnMyClickMessage(WPARAM wParam, LPARAM lParam)
{
	
	CComDispatchDriver spScript;
	IDispatch * pDocDisp = NULL;
   
   IHTMLDocument2  *pDoc=NULL;
   pDocDisp = m_MyIE.GetDocument(); 
   
   if (pDocDisp != NULL) 
   {
      // Obtained the document object by specifying the IHTMLDocument2 Interface.
		HRESULT hr= pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );
		
		pDoc->get_Script(&spScript);

		CComVariant varRet;  
		spScript.Invoke0(L"NoticeClient", &varRet); 

		CComDispatchDriver spData = varRet.pdispVal; 
		CComVariant varValue1;
		spData.GetPropertyByName(L"phone", &varValue1);

		CString strResult = _com_util::ConvertBSTRToString((_bstr_t)varValue1);

		szCharUrl.Format("%s%s", cUrls.QueryPhone, strResult);
		//szCharUrl.Format("http://www.baidu.com/s?wd=%s", strResult);
		//szCharUrl.Format("http://132.90.101.25:7001/portal");
		//szCharUrl.Format("http://132.77.51.11:7700/salemanm/salemanm?service=page/silverservice.silverJobExec.goldUnfinishedFrame&listener=initFrame&PROVINCEID=0011&STAFF_ID=yujp21&PASSWORD=H3B5VVJk0JFroCYwhWHbA9C8yes=&LOGIN_TYPE=KFSYS&inModeCode=1&cond_CONFIG=job&cond_FLAG=all&closeNavMethod=close&JOB_STATUS=1&VALID_FLAG=1&EPARCHY_CODE=0010&SERVER_NUMBER=18612452378");
		 
		CString sResult(_T(""));  
  
		// http://132.77.220.134:8081/window/servlet/CheckSerialNumber?serial_number=132.77.220.134
		

		//CString ip(tempUrl.Left(pos).rig);

		HttpRequestGet("132.77.220.134", 8081, "window/servlet/CheckSerialNumber?serial_number="+strResult, sResult);
		///m_MyIE.Navigate(szCharUrl, NULL, NULL, NULL, NULL);

   		//PostMessage(WM_SIZE,0,0);
   }
   return 1;
}
Ejemplo n.º 3
0
CComQIPtr<IHTMLElement> WebHandler::GetElement(
    CComQIPtr<IHTMLElementCollection> spElementCollection,
    const std::wstring& attrName, const std::wstring& attrValue,
    const std::wstring& textValue)
{
    long nItemCount = 0;				//取得表单数目
    HRESULT hr = spElementCollection->get_length(&nItemCount);
    if (FAILED(hr))
        return CComQIPtr<IHTMLElement>();

    for (long i = 0; i < nItemCount; i++)
    {
        CComDispatchDriver spDisp;	//取得第 j 项表单域
        hr = spElementCollection->item(CComVariant(i), CComVariant(), &spDisp);
        if (FAILED(hr))
            continue;

        CComQIPtr<IHTMLElement> spElement = spDisp;
        if (!spElement)
            break;

        bool bFind = false;
        std::wstring compareStr;

        if (attrName == L"class")
        {
            CComBSTR className;
            hr = spElement->get_className(&className);
            if (!FAILED(hr) && className)
            {
                compareStr = (LPCTSTR)className;
            }
         }   
         else
         {
             CComVariant vtAttr;
             hr = spDisp.GetPropertyByName(attrName.c_str(), &vtAttr);
             if (!FAILED(hr) && (vtAttr.vt == VT_BSTR) && (NULL != vtAttr.bstrVal))
             {
                 compareStr = (LPCTSTR)vtAttr.bstrVal;
             }
         }

        if (!compareStr.empty() && (compareStr.compare(attrValue) == 0))
        {
            if (textValue.empty())
            {
                bFind = true;
            }
            else
            {
                CComBSTR innerText;
                hr = spElement->get_innerText(&innerText);
                if (!FAILED(hr) && innerText)
                {
                    if ((textValue.compare((LPCTSTR)innerText) == 0))
                    {
                        bFind = true;
                    }
                }
            }
        }
        else
        {
            continue;
        }

        if (bFind)
        {
            return spElement;
        }
    }

    return CComQIPtr<IHTMLElement>();
}
Ejemplo n.º 4
0
void EnumForms(IHTMLDocument2 *pIHTMLDocument2)
{
	if(!pIHTMLDocument2) return;

	HRESULT hr;
	USES_CONVERSION;

	CComQIPtr< IHTMLElementCollection > spElementCollection;
	hr = pIHTMLDocument2->get_forms(&spElementCollection);	//取得表单集合
	if (FAILED(hr))
	{
		cout << _T("错误: 获取Form集合IHTMLElementCollection!") << endl;
		return;
	}

	long nFormCount = 0;				//取得表单数目
	hr = spElementCollection->get_length(&nFormCount);
	if (FAILED(hr))
	{
		cout << _T("错误: 获取Form集合IHTMLElementCollection的长度!") << endl;
		return;
	}
	
	cout << "Form对象共: " << nFormCount << endl;

	for(long i = 0; i < nFormCount; i++)
	{
		IDispatch *pDisp = NULL;		//取得第i个Form表单
		hr = spElementCollection->item(CComVariant(i), CComVariant(), &pDisp);
		if (FAILED(hr)) continue;

		CComQIPtr< IHTMLFormElement > spFormElement = pDisp;
		pDisp->Release();

		long nElemCount = 0;			//取得表单中域的数目
		hr = spFormElement->get_length(&nElemCount);
		if (FAILED(hr))	continue;

		for(long j = 0; j < nElemCount; j++)
		{
			CComDispatchDriver spInputElement;	//取得第 j 项表单域
			hr = spFormElement->item(CComVariant(j), CComVariant(), &spInputElement);
			if (FAILED(hr)) continue;

			CComVariant vName,vVal,vType;		//取得表单域的 名,值,类型
			hr = spInputElement.GetPropertyByName(L"name", &vName);
			if(FAILED(hr)) continue;
			hr = spInputElement.GetPropertyByName(L"value", &vVal);
			if(FAILED(hr)) continue;
			hr = spInputElement.GetPropertyByName(L"type", &vType);
			if(FAILED(hr)) continue;

			cout << _T("[") << (vType.bstrVal? OLE2CT(vType.bstrVal) : _T("")) << _T("] ")
				<< (vName.bstrVal? OLE2CT(vName.bstrVal) : _T(""))
				<< _T(" = ") 
				<< (vVal.bstrVal? OLE2CT(vVal.bstrVal ) : _T(""))
				<< endl;
		}
		//想提交这个表单吗?删除下面语句的注释吧
		//pForm->submit();
	}
}