Microsoft KB Archive/183413

= PRB: ShowHTMLDialog Returns E_NOINTERFACE (0x80004002) =

Article ID: 183413

Article Last Modified on 11/19/1999

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2

-



This article was previously published under Q183413



SYMPTOMS
ShowHTMLDialog returns an HRESULT of 0x80004002 - E_NOINTERFACE.



CAUSE
ShowHTMLDialog must be called from a thread that is a member of an apartment initialized by CoInitialize.



RESOLUTION
Change CoInitializeEx(NULL, COINIT_MULTITHREADED) calls to CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) or move the ShowHTMLDialog call to another thread that is apartment threaded.



STATUS
This behavior is by design.



MORE INFORMATION
The following code snippet demonstrates the problem:
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include 
 * 5) include 
 * 6) include 
 * 7) pragma comment(lib, "urlmon.lib")

int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,                    LPSTR lpCmdLine, int nCmdShow) {   HRESULT   hr; IMonikerPtr pmk; OLECHAR* pchHTML = L"http://www.microsoft.com"; SHOWHTMLDIALOGFN* pfnShowHTMLDialog = NULL; HINSTANCE hinstMSHTML = NULL;

// ***   // *** The following should be    // *** CoInitialize(NULL, COINIT_APARTMENTTHREADED); // ***   CoInitializeEx(NULL, COINIT_MULTITHREADED);

hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL"));

if (NULL != hinstMSHTML) {      pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*) GetProcAddress(hinstMSHTML, TEXT("ShowHTMLDialog")); }

if (NULL != pfnShowHTMLDialog) hr = CreateURLMoniker(NULL, pchHTML, &pmk);

if (SUCCEEDED(hr)) {      hr = pfnShowHTMLDialog(NULL,       // HWND        hwndParent,                              pmk,        // IMoniker *  pMk,                              NULL,       // TCHAR *     pchURL,                              NULL,       // VARIANT *   pvarArgIn,                              NULL        // VARIANT *   pvarArgOut,                              ); }

if (hinstMSHTML) FreeLibrary(hinstMSHTML);

CoUninitialize;

return 0; }

Keywords: kbprb kbcode KB183413

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.