本帖最后由 sammyke 于 2011-04-02 14:45:48 编辑

解决方案 »

  1.   

    那你直接用WebBrowser,去DocumentElement操作。必须把遨游做中介?
      

  2.   

    使用Process就可以了。
    System.Diagnose.Process p = new Process("遨游目录");
    p.StartInfo = "地址";
    p.Start();
      

  3.   

    void WINAPI GetWindowHwnd(){
    //获取窗体指针
    while ( true ){
    HWND HaWNDT = GetWindow( GetDesktopWindow() ,GW_CHILD);
    while ( HaWNDT = GetWindow(HaWNDT, GW_HWNDNEXT), HaWNDT != NULL ){
    if ( GetClassName(HaWNDT) != "wndclass_desked_gsk" ) continue;
    if ( GetWindowText(HaWNDT).Find("Document Explorer") == -1 ) continue;
    if ( GetWindowText(HaWNDT).Find("Combined Help Collection") == -1 ) continue;
    if ( GetWindowText(HaWNDT).Find("正在加载") != -1 ) continue;
    if ( ((CString)(PathFindFileName(GetProcessPath(GetWindowProcessId(HaWNDT))))).MakeLower() != "dexplore.exe" ) continue;

                BaMainForm = HaWNDT;
    }
    if ( (int)BaMainForm != 0 ) {
    break;
    }else{
    Sleep(100);
    }
    }

    //获取窗体上的元件
    HWND HaControlHandleOne,HaControlHandleTwo,HaControlHandleThree,HaControlHandleFour,HaControlHandleFive,
    HaControlHandleSix,HaControlHandleSeven,HaControlHandleEight,HaControlHandleNine,HaControlHandleTen; HaControlHandleOne = GetWindow(BaMainForm, GW_CHILD);
    while(HaControlHandleOne){
    if ( GetClassName(HaControlHandleOne) == "MDIClient" ) {
    HaControlHandleTwo = GetWindow(HaControlHandleOne, GW_CHILD);
    while(HaControlHandleTwo){
    if ( GetClassName(HaControlHandleTwo) == "EzMdiContainer" ) {
    HaControlHandleThree = GetWindow(HaControlHandleTwo, GW_CHILD);
    while(HaControlHandleThree){
    if ( GetClassName(HaControlHandleThree) == "DockingView" ) {
    HaControlHandleFour = GetWindow(HaControlHandleThree, GW_CHILD);
    while(HaControlHandleFour){
    if ( GetClassName(HaControlHandleFour) == "GenericPane" ) {
    HaControlHandleFive = GetWindow(HaControlHandleFour, GW_CHILD);
    while(HaControlHandleFive){
    if ( GetClassName(HaControlHandleFive) == "GenericPane" ) {
    HaControlHandleSix = GetWindow(HaControlHandleFive, GW_CHILD);
    while(HaControlHandleSix){
    if ( GetClassName(HaControlHandleSix) == "Shell Embedding" ) {
    HaControlHandleSeven = GetWindow(HaControlHandleSix, GW_CHILD);
    while(HaControlHandleSeven){
    if ( GetClassName(HaControlHandleSeven) == "Shell DocObject View" ) {
    HaControlHandleEight = GetWindow(HaControlHandleSeven, GW_CHILD);
    while(HaControlHandleEight){
    if ( GetClassName(HaControlHandleEight) == "Internet Explorer_Server" ) {
    BaWeb = HaControlHandleEight;
    }
    HaControlHandleEight = GetWindow(HaControlHandleEight, GW_HWNDNEXT);
    }
    }
    HaControlHandleSeven = GetWindow(HaControlHandleSeven, GW_HWNDNEXT);
    }
    }
    HaControlHandleSix = GetWindow(HaControlHandleSix, GW_HWNDNEXT);
    }
    }
    HaControlHandleFive = GetWindow(HaControlHandleFive, GW_HWNDNEXT);
    }
    }
    HaControlHandleFour = GetWindow(HaControlHandleFour, GW_HWNDNEXT);
    }
    }
    HaControlHandleThree = GetWindow(HaControlHandleThree, GW_HWNDNEXT);
    }
    }
    HaControlHandleTwo = GetWindow(HaControlHandleTwo, GW_HWNDNEXT);
    }
    }
    HaControlHandleOne = GetWindow(HaControlHandleOne, GW_HWNDNEXT);
    }
    }//返回IE句柄HTML
    CString GetHtmlText(HWND DaHwnd){
    CString Result = "";
    CoInitialize( NULL );
    HINSTANCE HaInst = LoadLibrary("OLEACC.DLL");
    if ( HaInst != NULL && DaHwnd != NULL ) {
    CComPtr<IHTMLDocument2> HaHtmlDoc;
    LPFNOBJECTFROMLRESULT HaObjectFromLresult = (LPFNOBJECTFROMLRESULT)GetProcAddress( HaInst, "ObjectFromLresult");
    if ( HaObjectFromLresult != NULL ) {
    UINT HaMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");
    LRESULT HaRes;
    SendMessageTimeout(DaHwnd, HaMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&HaRes);
    HRESULT hr = (*HaObjectFromLresult)(HaRes, IID_IHTMLDocument, 0, (void**)&HaHtmlDoc);
    if ( SUCCEEDED(hr) ) {
    USES_CONVERSION;
    CComPtr<IDispatch> spDisp;
    CComQIPtr<IHTMLWindow2> spWin;
    HaHtmlDoc->get_Script( &spDisp );
    spWin = spDisp;
    spWin->get_document( &HaHtmlDoc.p );
    //HaHtmlDoc->put_bgColor( CComVariant("red") );

    BSTR HaAadyState;
    int i = 0;
    while( i++ < 100 ){
    HaHtmlDoc->get_readyState(&HaAadyState);
    if ( (CString)OLE2T(HaAadyState) != "complete" ) {
    Sleep(25);
    }else{
    break;
    }
    } CComPtr<IHTMLElement> HaHtmlBody, HaHtmlHead;
    i = 0;
    while( i++ < 100 ){
    HaHtmlDoc->get_body(&HaHtmlBody);
    if ( HaHtmlBody == NULL ) {
    Sleep(25);
    }else{
    break;
    }
    } HaHtmlBody->get_parentElement(&HaHtmlHead);
    if ( HaHtmlHead == NULL ) return ""; BSTR HaHtmlText;
    HaHtmlHead->get_innerText(&HaHtmlText); 
    Result = (CString)OLE2T(HaHtmlText);
    }
    }
    }
    FreeLibrary(HaInst);
    CoUninitialize();
    return Result;
    }
      

  4.   

    谢谢wllllll,你的回答正是我想要的,不过不知道能否用到C#里,如果非得用C++,那我只能去研究下C++了,总之能用换个语言做也可以,就是做一个工具。
    4楼5楼的回答,你们应该是没认真看题,不过也麻烦你们顶贴了,
    还有其他朋友做过类似的吗?最好是C#的。
      

  5.   

    找IWebBrowser指针
    要对Com组件和C++有一定程度的了解才行
      

  6.   

    C#里面有UIAutomation类,这个也比较好用但是没有做过这样的例子,否则就发给你了
      

  7.   

    为什么不使用httpwebrequest/httpwebresponse呢?
      

  8.   

    [DllImport("user32.dll", EntryPoint = "FindWindow",CharSet = CharSet.Auto)]
    public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);//调用:
    IntPtr p = FindWindow("QQ2010","TXGuiFoundation");这个是获得窗口句柄的例子,你可以获得遨游浏览器的窗口句柄后,在去获取它子控件的句柄,这样你就可以给它填值了
      

  9.   

    我记得获取其他游览器(IE核心)的IE控件是不需要权限的,
    如果需要权限, 你只能DLL注入到目标程序里去了.
    我写的GetHtmlText..不知道如何改成C#