Skip to content

Instantly share code, notes, and snippets.

@anekos
Created January 4, 2014 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anekos/8256104 to your computer and use it in GitHub Desktop.
Save anekos/8256104 to your computer and use it in GitHub Desktop.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
// アセンブリに関連付けられている情報を変更するには、
// これらの属性値を変更してください。
[assembly: AssemblyTitle("BatteryLevelSender")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BatteryLevelSender")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
// その型の ComVisible 属性を true に設定してください。
[assembly: ComVisible(false)]
// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
[assembly: Guid("4f4d5409-371a-4eee-9fa8-6717d7913b39")]
// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Management;
using System.Windows.Forms;
using System.Web;
using System.Net;
using System.Collections.Specialized;
namespace BatteryLevelSender
{
class Program
{
static void Main(string[] args)
{
Encoding enc = Encoding.UTF8;
String name = args[0];
PowerStatus ps = SystemInformation.PowerStatus;
Console.WriteLine(ps.BatteryLifePercent);
int level = (int)(ps.BatteryLifePercent * 100);
WebClient wc = new WebClient();
String res = enc.GetString(wc.DownloadData("http://example.com/level/" + name + "/" + level));
Console.WriteLine(res);
// Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment