6.4-6.11台湾行

2016-6-16 摄影

6.4深圳-桃园机场-高雄-垦丁

6.5垦丁

6.6垦丁-高雄-台中-蓬甲夜市

6.7台中-日月潭-台中-台北

6.8故宫博物馆-淡水中学-淡水老街-士林夜市

6.9mr.j餐厅-诚品书店-微风广场-电影-101-鼎泰丰-base10夜店

6.10台北-瑞芳-十分-猫园-九份-宁夏夜市

6.11 台北-王品-桃园机场-深圳

标签: 台湾 旅游

评论(0) 浏览(2327)

通过HWND获取WebBrowser内容

2016-4-20 C++

参考资料:https://support.microsoft.com/en-us/kb/249232

已知一个窗口的HWND及窗口类为“Internet Explorer_Server",获取显示的内容!

#include <mshtml.h>

#include <atlbase.h>

#include <oleacc.h>


BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)

{

    TCHAR buf[256] = { 0 };

    ::GetClassName(hwnd, buf, 256);

    if (_tcscmp(buf, _T("Internet Explorer_Server")) == 0)

    {

        *(HWND*)lParam = hwnd;

        return FALSE; //退出循环

    }

    return TRUE;

}


void GetDocInterface(HWND hWnd)

{

    CoInitialize(NULL);

    HINSTANCE hInst = ::LoadLibrary(_T("OLEACC.DLL");

    if (hInst != NULL && hWnd != NULL)

    {

        HWND hWndChild = NULL;

        ::EnumChildWindows(hWnd, EnumChildProc, (LPARAM)&hWndChild);

        if (hWndChild)

        {

            CComPtr<IHTMLDocument2> spDoc;

            LRESULT lRes;

            

            UINT nMsg = ::RegisterWindowMessage(_T("WM_HTML_GETOBJECT"));

            ::SendMessageTimeout(hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes);

            LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress(hInst, _T("ObjectFromLresult"));

            if (pfObjectFromLresult != NULL)

            {

                HRESULT hr = (*pfObjectFromLresult )(lRes, IID_IHTMLDocument2, 0, (void**)&spDoc);

                if (SUCCEEDED(hr))

                {

                    IHTMLElement *p = NULL;

                    spDoc->get_body(&p); //接下去就跟操作IE一样

                }

            }

        }

        ::FreeLibrary(hInst);

    }

    ::CoUninitialize();

}

标签: HWND Internet Explorer_Server

评论(0) 浏览(3418)

android 开启wifi热点api

2016-3-13 android

android默认开启wifi热点方式只能通过设置-移动网络共享-便携式wlan热点,为了开启一个热点要进行3部操作,实属麻烦!

因此通过网上查资料,实现wifi热点的一键启动!

通过google获知,android把wifi相关的api给隐藏了,因此只能通过反射机制进行调用!

  /**

    * Start AccessPoint mode with the specified

    * configuration. If the radio is already running in

    * AP mode, update the new configuration

    * Note that starting in access point mode disables station

    * mode operation

    * @param wifiConfig SSID, security and channel details as

    *        part of WifiConfiguration

    * @return {@code true} if the operation succeeds, {@code false} otherwise

    *

    * @hide Dont open up yet

    */

   public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {

       try {

           mService.setWifiApEnabled(wifiConfig, enabled);

           return true;

       } catch (RemoteException e) {

           return false;

       }

   }

配置AP的选项是属于wifi管理的一部分!获取当前系统wifi实例的方式如下:

WifiManger manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

获取当前ap状态的方式如下:

public Boolean getApState() {

    Boolean bApState = FALSE;

    try {

             Method method = manager.getClass().getMethod("isWifiApEnabled");

             bApState = (Boolean)method.invoke(manager);

     } catch (Exception e) {

        e.printStackTrace();

         bApState = FALSE;

    }

    return bApState;

}

配置ap使用的类为:WifiConfiguration //本例直接采用默认配置好的

public WifiConfiguration getApConfiguration() {

    WifiConfiguration apConfigure = new WifiConfiguretion();

    return apConfigure;

}

      使能ap方式如下:

public void setWifiAp(Boolean bOpen) {

    if (bOpen) {

        if (getApState()) {

            return;

        }

        manager.setWifiEnabled(false);

    }

    try {

       Method method = manager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, Boolean.TYPE);

       method.invoke(manager, getApConfiguration()/*采用默认的配置,则置为null*/, bOpen);

    } catch (Exception e) {

        e.printStackTrance();

    }

}

源码已上传到github:https://github.com/aqi/WifiAssistant

标签: android wifiAp

评论(0) 浏览(4992)

Powered by EMLOG Copyright @ 深圳市炽旗科技 版权所有. 闽ICP备14012694号-2