Click here to Skip to main content
15,913,773 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: Logging as windows system account Pin
led mike19-Dec-06 4:52
led mike19-Dec-06 4:52 
Questionhuffman code Pin
hamzeee18-Dec-06 11:32
hamzeee18-Dec-06 11:32 
AnswerRe: huffman code Pin
Paul Conrad27-Dec-06 18:23
professionalPaul Conrad27-Dec-06 18:23 
QuestionProject Runtime Library Option Pin
ajitatif angajetor18-Dec-06 1:12
ajitatif angajetor18-Dec-06 1:12 
AnswerRe: Project Runtime Library Option Pin
Michael Dunn18-Dec-06 6:47
sitebuilderMichael Dunn18-Dec-06 6:47 
AnswerRe: Project Runtime Library Option Pin
ajitatif angajetor19-Dec-06 23:12
ajitatif angajetor19-Dec-06 23:12 
GeneralRe: Project Runtime Library Option Pin
Stuart Dootson19-Dec-06 23:32
professionalStuart Dootson19-Dec-06 23:32 
QuestionIHTMLLocation, hr = 0x80040154 Pin
Jeffrey Walton17-Dec-06 22:31
Jeffrey Walton17-Dec-06 22:31 
Hi All,

I want to use MSHTML as a parser from a Console Application.
hr = Location.CoCreateInstance(CLSID_HTMLLocation);
is returning 'COM Error: 0x80040154 (Win32: 340)'

Any ideas? The Document creation returns S_OK.
Jeff

// #define _WIN32_IE 0x0400    // IHTMLDocument2
#define _WIN32_IE 0x0550    // IHTMLDocument2
#define _WIN32_DCOM         // CoInitializeEx(...)

#pragma warning( disable: 4146 )
#pragma warning( disable: 4192 )
#  import "mshtml.tlb"    // guids
#pragma warning( default: 4146 )
#pragma warning( default: 4192 )

#include <windows.h>

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

#include <iostream>

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

    CComPtr< MSHTML::IHTMLDocument2 > Document = NULL;
    CComPtr< MSHTML::IHTMLLocation >  Location = NULL;

    hr = CoInitializeEx( NULL, COINIT_MULTITHREADED  );
    if( FAILED( hr ) ) { goto COMPLETE; }

    hr = Document.CoCreateInstance(CLSID_HTMLDocument);
    if( FAILED( hr ) ) { goto COMPLETE; }
<BR>
    hr = Location.CoCreateInstance(CLSID_HTMLLocation);
    if( FAILED( hr ) ) { goto COMPLETE; }

    // hr = Document->get_location( &Location );
    // if( FAILED( hr ) ) { goto COMPLETE; }

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

COMPLETE:

    // Smart pointers are not always very smart
    //  Destroy these objects before
    //  CoUninitialize() is invoked
    // CComPtr<> outlives the apartment
    //   created by CoInitializeEx(). 
    Document.Release();
    Location.Release();

    CoUninitialize( );

    if( S_OK != hr )
    {
        std::wcout << L"COM Error: " << std::hex << L"0x" <<hr;
        std::wcout << L" (Win32: " << std::dec << HRESULT_CODE( hr );
        std::wcout << L")" << std::endl;
    }

    return HRESULT_CODE( hr );
}

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 
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 

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.