Click here to Skip to main content
15,909,829 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionIHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton17-Dec-06 22:31
Jeffrey Walton17-Dec-06 22:31 
AnswerRe: IHTMLLocation, hr = 0x80040154 Pin
Stuart Dootson18-Dec-06 0:57
professionalStuart Dootson18-Dec-06 0:57 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton18-Dec-06 4:31
Jeffrey Walton18-Dec-06 4:31 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton18-Dec-06 4:45
Jeffrey Walton18-Dec-06 4:45 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton23-Dec-06 19:01
Jeffrey Walton23-Dec-06 19:01 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton24-Dec-06 8:22
Jeffrey Walton24-Dec-06 8:22 
AnswerRe: IHTMLLocation, hr = 0x80040154 Pin
User 21559718-Dec-06 1:06
User 21559718-Dec-06 1:06 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton18-Dec-06 4:30
Jeffrey Walton18-Dec-06 4:30 
Hi Sohail,

Still fighting it... I'm working from Lightweight HTML Parsing Using MSHTML [^]. The new program is below, but same error occurs on IMarkupServices:

COM Error:
pDocument->QueryInterface( IMarkupServices )
0x80004002 (Win32: 16386)

I tried to unregister, and then register mshtml.dll. Unregister failed with 0x80004002 or 0x80004005. Registration succeeded.

I'm using Visual Studio 6.0, EE on Windows 2000. At this point, I rolled back the March 2006 SDK because of LINK 1103 error (corrupt library) to October 2002. I'm downloading February 2003 SDK now (last supported version for VC++ 6.0). I verified the IE SDK was installed.

I'm going to start to grep the Registry.

Jeff

#define _WIN32_IE 0x0500    // IMarkupServices
#define _WIN32_DCOM         // CoInitializeEx(...)

#import "mshtml.tlb"    // guids

#include <windows.h>

#include <atlbase.h>    // CComPtr<>, CoInitializeEx, etc
#include <mshtml.h>     // MSHTML Object and Interfaces
#include <mshtmlc.h>    // IID_IMarkupServices
#include <assert.h>

// IID_IMarkupServices;
//    MIDL_INTERFACE("3050f4a0-98b5-11cf-bb82-00aa00bdce0b")

// Standard C++ Library
#include <iostream>

int main(int argc, char* argv[])
{
    HRESULT hr = S_OK;
    CComBSTR    error; 

    try
    {
        CComPtr< MSHTML::IHTMLDocument2 >    pDocument = NULL;
        CComPtr< IPersistStreamInit >          pStream = NULL;
        CComPtr< MSHTML::IMarkupServices >   pServices = NULL;
        CComPtr< MSHTML::IMarkupContainer > pContainer = NULL;
        //CComPtr< MSHTML::IHTMLLocation >   pLocation = NULL;

        CComBSTR title = L"", charset=L"";

        ///////////////////////////////////////////////////////////////////
        // Call CoInitialize to initialize the COM library
        hr = CoInitializeEx( NULL, COINIT_MULTITHREADED  );
        if( FAILED( hr ) ) {
            error = L"CoInitializeEx";
            throw error;
        }

        ///////////////////////////////////////////////////////////////////
        // Create a Document to bootstrap the process
        hr = pDocument.CoCreateInstance( CLSID_HTMLDocument );
        if( FAILED( hr ) ) {
            error = L"pDocument";
            throw error;
        }
    
        ///////////////////////////////////////////////////////////////////
        hr = pDocument->get_title( &title );
        if( FAILED( hr ) )
        {
            error = L"pDocument->get_title";
            throw error;
        }

        std::wcout << L"Title: ";
        std::wcout << (wchar_t*)title << std::endl;

        hr = pDocument->get_charset( &charset );
        if( FAILED( hr ) )
        {
            error = L"pDocument->get_charset";
            throw error;
        }

        std::wcout << L"Character Set: ";
        std::wcout << (wchar_t*)charset << std::endl;

        ///////////////////////////////////////////////////////////////////
        // Document->QueryInterface( __uuidof( IPersistStreamInit ) ) );
        hr = pDocument->QueryInterface( IID_IPersistStreamInit,
                                        reinterpret_cast<void**>( &pStream ) );
        if( FAILED( hr ) ) {
            error = L"pDocument.QueryInterface( IPersistStreamInit )";
            throw error;
        }
        pStream->InitNew();
        
        ///////////////////////////////////////////////////////////////////
        // Document->QueryInterface( __uuidof( MSHTML::IMarkupServices ) )
        hr = pDocument->QueryInterface( IID_IMarkupServices,
                                        reinterpret_cast<void**>( &pServices ) );
        //                                // NULL, CLSCTX_INPROC_SERVER );
        //MSHTML::IMarkupServices::CreateMarkupContainer
        if( FAILED( hr ) ) {
            error = L"pDocument->QueryInterface( IMarkupServices )";
            throw error;
        }

        // hr = Container.CoCreateInstance(CLSID_MarkupContainer);
        // if( FAILED( hr ) ) { goto COMPLETE; }

        // std::wcout << L"pDocument URL: ";
        // std::wcout << (wchar_t*)pLocation->toString() << std::endl;

    }

    catch( CComBSTR& e )
    {
        std::wcout << std::endl;
        std::wcout << L"COM Error: " << std::endl << L"  ";
        std::wcout << (wchar_t*)e << std::endl ;
        std::wcout << std::hex << L"  0x" <<hr;
        std::wcout << L" (Win32: " << std::dec << HRESULT_CODE( hr );
        std::wcout << L")" << std::endl;
    }

    CoUninitialize( );

    return HRESULT_CODE( hr );
}

GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
User 21559718-Dec-06 4:52
User 21559718-Dec-06 4:52 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
User 21559718-Dec-06 4:55
User 21559718-Dec-06 4:55 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton18-Dec-06 14:40
Jeffrey Walton18-Dec-06 14:40 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton24-Dec-06 8:26
Jeffrey Walton24-Dec-06 8:26 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
User 21559724-Dec-06 12:08
User 21559724-Dec-06 12:08 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton24-Dec-06 12:26
Jeffrey Walton24-Dec-06 12:26 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
User 21559725-Dec-06 0:25
User 21559725-Dec-06 0:25 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton18-Dec-06 4:46
Jeffrey Walton18-Dec-06 4:46 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton23-Dec-06 19:01
Jeffrey Walton23-Dec-06 19:01 
AnswerRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton23-Dec-06 19:03
Jeffrey Walton23-Dec-06 19:03 
GeneralRe: IHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton24-Dec-06 8:22
Jeffrey Walton24-Dec-06 8:22 
QuestionAdding events in Automation server Pin
User 21559715-Dec-06 1:18
User 21559715-Dec-06 1:18 
QuestionIContextMenu2 and Menu Icon Pin
Jeffrey Walton13-Dec-06 23:22
Jeffrey Walton13-Dec-06 23:22 
QuestionContext Menu Handler and InsertMenu Pin
Jeffrey Walton13-Dec-06 19:02
Jeffrey Walton13-Dec-06 19:02 
AnswerRe: Context Menu Handler and InsertMenu Pin
Michael Dunn13-Dec-06 19:51
sitebuilderMichael Dunn13-Dec-06 19:51 
GeneralRe: Context Menu Handler and InsertMenu Pin
Jeffrey Walton13-Dec-06 23:00
Jeffrey Walton13-Dec-06 23:00 
GeneralRe: Context Menu Handler and InsertMenu Pin
Jeffrey Walton13-Dec-06 23:06
Jeffrey Walton13-Dec-06 23:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.