Skip to content

Instantly share code, notes, and snippets.

@variux
Created February 6, 2018 14:03
Show Gist options
  • Save variux/fa454754a173940df3774eab6bda65fe to your computer and use it in GitHub Desktop.
Save variux/fa454754a173940df3774eab6bda65fe to your computer and use it in GitHub Desktop.
#Esto va en el load
if (VerifyLicense() == false)
{
MessageBox.Show("Licencia vencida contacte a ITCO para continuar");
Environment.Exit(1);
}
//la funcion
private bool VerifyLicense() {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://itco.space/activate.php");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
string license = File.ReadLines(@"C:\Program Files (x86)\ITCO S.A\Factura Electronica\license.txt").First();
string postData = "sn="+license;
byte[] data = Encoding.UTF8.GetBytes(postData);
Stream dataStream = request.GetRequestStream();
dataStream.Write(data, 0, data.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
if (responseFromServer == "601")
{
return true;
}
else {
return false;
}
}
//ONexit reemplazar
Environment.Exit(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment