Commit 703a941d authored by 黄奎's avatar 黄奎

页面修改

parent eba90070
......@@ -54,60 +54,5 @@ namespace EduSpider
Console.ReadLine();
Environment.Exit(0);
}
#region 异常 退出chromedriver
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "SendMessage")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
public const int SW_HIDE = 0;
public const int SW_SHOW = 5;
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
/// <summary>
/// 获取窗口句柄
/// </summary>
/// <returns></returns>
public IntPtr GetWindowHandle()
{
string name = (Environment.CurrentDirectory + "\\chromedriver.exe");
IntPtr hwd = FindWindow(null, name);
return hwd;
}
/// <summary>
/// 关闭chromedriver窗口
/// </summary>
public void CloseWindow()
{
try
{
IntPtr hwd = GetWindowHandle();
SendMessage(hwd, 0x10, 0, 0);
}
catch
{
}
}
/// <summary>
/// 退出chromedriver
/// </summary>
/// <param name="driver"></param>
public void CloseChromeDriver(IWebDriver driver)
{
try
{
driver.Quit();
driver.Dispose();
}
catch
{
}
CloseWindow();
}
#endregion 异常 退出chromedriver
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment