Click to See Complete Forum and Search --> : SHDocVw DLL Question


yolip
December 3rd, 2008, 08:35 PM
Hi Guys,

I am using .NET 2 and trying to use SHDocVw.dll to print a html file to the printer, however, I found most of the time if i step line by line will works, but won't work during the runtime. The error is: Trying to revoke a drop target that has not been registered (Exception from HRESULT: 0x80040100 (DRAGDROP_E_NOTREGISTERED))

any idea?

Thanks


public bool Print_HTML_File(string path)
{
try
{
SHDocVw.InternetExplorer _ie = new SHDocVw.InternetExplorerClass();


Object o = new Object();
_ie.Navigate(path, ref o, ref o, ref o, ref o);
_ie.Visible = false;
_ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
ref o, ref o);

_ie=null;
o=null;
return true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.Print(ex.Message);
return false;
}

}

cjard
December 9th, 2008, 07:56 PM
try printing after the document has loaded (document complete event fires) and don't start destroying objecst until things have printed

HanneSThEGreaT
December 10th, 2008, 02:18 AM
http://www.dotnetspider.com/resources/18307-Printing-HTML-Pages-WIndows-Application-using.aspx

http://www.codeproject.com/KB/toolbars/MicrosoftMshtml.aspx?display=Print