berbagi pusing lagi neh.. soal UTS network programming 2.. kemungkinan soalnya beda.. tapi..
ah sudahlah.. kali aja sama.. kalopun beda yah itung2 buat referensi.. wkwkk..
sekilas soal :
form menampilkan informasi pc dan ip address
form terdiri dari 14 label, 1 richtextbox, 1 button
awal running button text= tampilkan informasi, ketika diklik akan tampil informasi dan ip address lalu button text berubah jadi "keluar"
neh form awalnya:
neh pas diklik buttonnya:
tapi gatau dah kenapa ip nya ga nongol.. padahal udah nyetting ip tapi tetep aja belom kebaca.. hmmmmm.. masih menjadi misteri piss ^^V
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO;
namespace UTS_TIPE_A
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;
this.MaximizeBox = false;
this.MinimizeBox = false;
richTextBox1.ReadOnly = true;
}
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "Keluar";
RegistryKey buka = Registry.LocalMachine;
RegistryKey nama = buka.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
RegistryKey os = buka.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
RegistryKey proci = buka.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
RegistryKey arsitek = buka.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
RegistryKey manufaktur = buka.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\BIOS");
RegistryKey mobo = buka.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\BIOS");
labelpc.Text = Convert.ToString(nama.GetValue("RegisteredOwner"));
labelos.Text = Convert.ToString(os.GetValue("ProductName"));
labelpro.Text = Convert.ToString(proci.GetValue("ProcessorNameString"));
labelars.Text = Convert.ToString(arsitek.GetValue("Identifier"));
labelman.Text = Convert.ToString(manufaktur.GetValue("SystemManufacturer"));
labelmot.Text = Convert.ToString(mobo.GetValue("SystemProductName"));
StringBuilder addtext = new StringBuilder();
RegistryKey kartujaringan = buka.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\14");
addtext.AppendLine("Kartu Network : " + Convert.ToString(kartujaringan.GetValue("Description")));
RegistryKey netkey = buka.OpenSubKey("SYSTEM\\CurrentControlSet\\services" + ((string)kartujaringan.GetValue("ServiceName")) + "\\Parameters\\Tcpip");
if (netkey == null)
{
MessageBox.Show("Belum Ada Konfigurasi IP", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
string[] alamatip = (string[])netkey.GetValue("IPAddress");
string[] subnetmask = (string[])netkey.GetValue("SubnetMask");
string[] defaultgateway = (string[])netkey.GetValue("DefaultGateway");
string[] defaultdns = (string[])netkey.GetValue("DefaultDns");
if (alamatip != null || subnetmask != null || defaultdns != null || defaultgateway != null)
{
foreach (string ipaddress in alamatip)
{
addtext.AppendLine("IP Address : " + alamatip);
}
foreach (string subnet in subnetmask)
{
addtext.AppendLine("Subnet Mask : " + subnetmask);
}
foreach (string gateway in defaultgateway)
{
addtext.AppendLine("Default Gateway : " + defaultgateway);
}
foreach (string dns in defaultdns)
{
addtext.AppendLine("Default DNS : " + defaultdns);
}
}
}
richTextBox1.AppendText(addtext.ToString());
}
}
}
udah ah segitu aja.. kalo ada kurangnya yah maklum lah..
kalo ada lebihnya.. tolong dibalikin.. kkkkkk bercanda ^^V
0 comments:
Post a Comment