Eu estava buscando alguma coisa na internet para me auxiliar no teste para identificar endereço é válido. o que eu achei funciona que é uma blz, mas ele fica abrindo as pastar ou as paginas na internet nas respectivas janelas.
o código que eu tenho é este.: todos meu arquivo. Lembrando que em mProcesso.StartInfo.CreateNoWindow = true; // tentei com false tb
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Utils
{
public class Internet
{
//Método da API
[DllImport("wininet.dll")]
private extern static Boolean InternetGetConnectedState(out int Description, int ReservedValue);
/// <summary>
/// verificar se está conectado a rede
/// </summary>
/// <returns></returns>
public static Boolean IsConnected()
{
int Description;
return InternetGetConnectedState(out Description, 0);
}
public static Boolean ConnectedStateIn(string locale)
{
bool status = true;
// Se a internet esta conectada
if (IsConnected())
{
Process mProcesso = new Process();
// indica se deve usar o shell do sistema
// operacional para iniciar o processo
mProcesso.StartInfo.UseShellExecute = true;
// podemos iniciar qualquer processo
mProcesso.StartInfo.FileName = locale;
// indica se o processo deve iniciar em uma nova janela
mProcesso.StartInfo.CreateNoWindow = true; // tentei com false tb
mProcesso.Start();
}
else
{
status = false;
}
return status;
}
}
}
e uso desta forma:
Internet.ConnectedStateIn("http://www.dominio.br"
dentro também testo “C:\controle”