Friday, January 25, 2013
Thursday, January 24, 2013
C# Get My Public IP Address using ifconfig.me
using System;
using System.IO;
using System.Net;
private string createRequest(string url, string method)
{
var request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = "curl";
request.Method = method;
using (WebResponse response = request.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
return (reader.ReadToEnd());
}
}
}
string myIP = createRequest("http://ifconfig.me", "GET").Replace("\n", "");
using System.IO;
using System.Net;
private string createRequest(string url, string method)
{
var request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = "curl";
request.Method = method;
using (WebResponse response = request.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
return (reader.ReadToEnd());
}
}
}
string myIP = createRequest("http://ifconfig.me", "GET").Replace("\n", "");
C# Put Dispaly in Sleep Mode
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
//OFF
SendMessage(this.Handle, 0x0112, (IntPtr)0xF170, (IntPtr)2);
//ON
SendMessage(this.Handle, 0x0112, (IntPtr)0xF170, (IntPtr)(-1));
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
//OFF
SendMessage(this.Handle, 0x0112, (IntPtr)0xF170, (IntPtr)2);
//ON
SendMessage(this.Handle, 0x0112, (IntPtr)0xF170, (IntPtr)(-1));
Subscribe to:
Posts (Atom)