Здрасте всем! Есть к примеру пару прокси ip:port.
Подключаюсь к ним так:
using Microsoft.Win32;
using System.Diagnostics;
using System.Runtime.InteropServices;
[DllImport("wininet.dll")]
public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
public const int INTERNET_OPTION_SETTINGS_CHANGED = 39;
public const int INTERNET_OPTION_REFRESH = 37;
private void ConnectToProxy(string proxy)
{
RegistryKey regKey = Registry.CurrentUser;
regKey = regKey.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings");
regKey.SetValue("ProxyEnable", 1); // 0 - отключиться, 1 - подключиться
regKey.SetValue("ProxyServer", proxy);
regKey.Close();
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
ProcessStartInfo psi = new ProcessStartInfo(Environment.SystemDirectory + @"\netsh.exe", "winhttp import proxy source=ie");
Process.Start(psi);
}
нужно узнать задержку(ping) прокси, как это сделать?
P.S. Спасибо большое!