WebBrowser窗口自動滾動:
this.webBrowser.Document.Window.ScrollTo(0, webBrowser1.Document.Body.ScrollRectangle.Height);
WebBrowser的腳本出錯信息:
當頁面上的腳本出錯時,一般情況下會彈出腳本出錯提示,如果在用WB寫爬蟲一類的時候,這類提示可能會導致系統不能工作,解決的發是:
(1)設置屬性ScriptErrorsSurpressed = true;
(2)打開IE的設置 "Internet選項" - "高級" - 勾選"禁用腳本調試"
WebBrowser的內存釋放:
WB的內存開銷很大,當連續打開很多網頁時這個問題將會非常明顯,甚至耗盡內存,解決的方我在MSDN論壇上找到(來源:
http://social.msdn.microsoft.com/Forums/en-US/ieextensiondevelopment/thread/88c21427-e765-46e8-833d-6021ef79e0c8/),具體如下:
This solution worked for me!!
Thank you so much mike_t2e!!!!!!!
-----------------------------------------------------------------------
Is the memory released when you minimize the app ? If so, try this:
-- in class definition
[DllImport("KERNEL32.DLL", EntryPoint = "SetProcessWorkingSetSize", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
internal static extern bool SetProcessWorkingSetSize(IntPtr pProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize);
[DllImport("KERNEL32.DLL", EntryPoint = "GetCurrentProcess", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
internal static extern IntPtr GetCurrentProcess();
-- code to call when you want to reduce the memory
IntPtr pHandle = GetCurrentProcess();
SetProcessWorkingSetSize(pHandle, -1, -1);
Thank you so much mike_t2e!!!!!!!
-----------------------------------------------------------------------
Is the memory released when you minimize the app ? If so, try this:
-- in class definition
[DllImport("KERNEL32.DLL", EntryPoint = "SetProcessWorkingSetSize", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
internal static extern bool SetProcessWorkingSetSize(IntPtr pProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize);
[DllImport("KERNEL32.DLL", EntryPoint = "GetCurrentProcess", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
internal static extern IntPtr GetCurrentProcess();
-- code to call when you want to reduce the memory
IntPtr pHandle = GetCurrentProcess();
SetProcessWorkingSetSize(pHandle, -1, -1);