Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Tue, 9 Oct 2007 05:48:02 -0700,    group: microsoft.public.inetsdk.programming.webbrowser_ctl        back       


SHDocVw::ShellWindows problem with vista   
I am using the following piece of code to check whether there is an instance 
of IE running on the system. It works fine for IE 6,7 on Xp. But on vista 
this code doesnt seem to work. I am not able to create an instance of 
SHDocVw::ShellWindows. It gives an ERROR_NO_TOKEN. 

                HRESULT hr;
	UINT ieWindowCount = 0;
	SHDocVw::IShellWindowsPtr spSHWinds;
	hr = spSHWinds.CreateInstance
                 (__uuidof(SHDocVw::ShellWindows));

	if (FAILED (hr))
	{
	  return false;
	}

	long nCount = spSHWinds->GetCount(); // total number of explorer windows
	IDispatchPtr spDisp;

	// check whether its an explorer window or an IE window.
	for (long i = 0; i < nCount; i++)
	{
		_variant_t va (i, VT_I4);
		spDisp = spSHWinds->Item (va);
		IWebBrowser2 * pWebBrowser = NULL;
		hr = spDisp.QueryInterface (IID_IWebBrowser2, &
									pWebBrowser);
		if (pWebBrowser != NULL)
		{
			HRESULT hr;
            IDispatch* pHtmlDocDispatch = NULL;
            IHTMLDocument2 * pHtmlDoc = NULL;
            
            // Retrieve the document object.
            hr = pWebBrowser->get_Document (&pHtmlDocDispatch);
            
            if (SUCCEEDED (hr) && (pHtmlDocDispatch != NULL))
            {
                // query for the html document's interface...
                hr = pHtmlDocDispatch->QueryInterface 
                   (IID_IHTMLDocument2,  (void**)&pHtmlDoc);
                if (SUCCEEDED (hr) && (pHtmlDoc != NULL))
                {
					ieWindowCount++;			
					if (ieWindowCount > 0)
						return TRUE;
				}
			}
		}
	}



Can anyone please help me in this regard or suggest me a better way to find 
if an instance of IE is running.

Thanks in advance
date: Tue, 9 Oct 2007 05:48:02 -0700   author:   Rohit Kumar

Re: SHDocVw::ShellWindows problem with vista   
I think you need run the process as administrator or turn off UAC.

-- 
Sheng Jiang
Microsoft MVP in VC++
"Rohit Kumar"  wrote in message
news:09D0D835-B919-4AC0-931E-3B915D0628A9@microsoft.com...
> I am using the following piece of code to check whether there is an
instance
> of IE running on the system. It works fine for IE 6,7 on Xp. But on vista
> this code doesnt seem to work. I am not able to create an instance of
> SHDocVw::ShellWindows. It gives an ERROR_NO_TOKEN.
>
>                 HRESULT hr;
> UINT ieWindowCount = 0;
> SHDocVw::IShellWindowsPtr spSHWinds;
> hr = spSHWinds.CreateInstance
>                  (__uuidof(SHDocVw::ShellWindows));
>
> if (FAILED (hr))
> {
>   return false;
> }
>
> long nCount = spSHWinds->GetCount(); // total number of explorer windows
> IDispatchPtr spDisp;
>
> // check whether its an explorer window or an IE window.
> for (long i = 0; i < nCount; i++)
> {
> _variant_t va (i, VT_I4);
> spDisp = spSHWinds->Item (va);
> IWebBrowser2 * pWebBrowser = NULL;
> hr = spDisp.QueryInterface (IID_IWebBrowser2, &
> pWebBrowser);
> if (pWebBrowser != NULL)
> {
> HRESULT hr;
>             IDispatch* pHtmlDocDispatch = NULL;
>             IHTMLDocument2 * pHtmlDoc = NULL;
>
>             // Retrieve the document object.
>             hr = pWebBrowser->get_Document (&pHtmlDocDispatch);
>
>             if (SUCCEEDED (hr) && (pHtmlDocDispatch != NULL))
>             {
>                 // query for the html document's interface...
>                 hr = pHtmlDocDispatch->QueryInterface
>                    (IID_IHTMLDocument2,  (void**)&pHtmlDoc);
>                 if (SUCCEEDED (hr) && (pHtmlDoc != NULL))
>                 {
> ieWindowCount++;
> if (ieWindowCount > 0)
> return TRUE;
> }
> }
> }
> }
>
>
>
> Can anyone please help me in this regard or suggest me a better way to
find
> if an instance of IE is running.
>
> Thanks in advance
>
date: Wed, 10 Oct 2007 17:21:54 -0500   author:   Sheng Jiang[MVP] uss

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us