TUTORIAL MEMBUAT HOTSPOT ENGINE DI C#
1. Buka Application Microsoft Visual Studio.
2.Pilih New > File > Project.
3.Pilih "Windows Forms Application" dan beri namanya. Kemudian pilih "OK".
4.Komponen yang digunakan :
5.Desain Form dengan memasukkan semua component hingga seperti di bawah ini dan ubah nama form menjadi "Hotspot Engine".
6.Masuk ke bagian Form1.cs
Masukkan Coding
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Principal;
using System.Net;
using System.Diagnostics;
namespace Virtual_Hotspot
{
public partial class Form1 : Form
{
bool connect = false;
public Form1()
{
InitializeComponent();
}
private void Hotspot (string ssid,string key, bool Status)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe");
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
Process process = Process.Start(processStartInfo);
if (process != null)
{
if (Status)
{
process.StandardInput.WriteLine("netsh wlan set hostednetwork mode=allow ssid=" + ssid + " key=" + key);
process.StandardInput.WriteLine("netsh wlan start hostednetwork");
process.StandardInput.Close();
}
else
{
process.StandardInput.WriteLine("netsh stop hostednetwork");
process.StandardInput.Close();
}
}
}
public static bool IsAdmin()
{
WindowsIdentity id = WindowsIdentity.GetCurrent();
WindowsPrincipal p = new WindowsPrincipal(id);
return p.IsInRole(WindowsBuiltInRole.Administrator);
}
public void RestartElevated()
{
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.UseShellExecute = true;
startinfo.CreateNoWindow = true;
startinfo.WorkingDirectory = Environment.CurrentDirectory;
startinfo.FileName = System.Windows.Forms.Application.ExecutablePath;
startinfo.Verb = "runas";
try
{
Process p = Process.Start(startinfo);
}
catch
{ }
System.Windows.Forms.Application.Exit();
}
--------------------------------------------------------------------------------------------------------------------------
6A. Coding button1 :
{
string ssid = textBox1.Text,key = textBox2.Text;
if (!connect)
{
if (textBox1.Text == null || textBox1.Text == "")
{
MessageBox.Show("Anda belum mengisi SSID", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (textBox2.Text == null || textBox2.Text == "")
{
MessageBox.Show("Anda Belum Mengisi Password!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (key.Length >= 6)
{
Hotspot(ssid, key, true);
textBox1.Enabled = false;
textBox2.Enabled = false;
button1.Text = "Berhenti";
connect = true;
}
else
{
MessageBox.Show("Password harus 6 karakter atau lebih!", "informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
else
{
Hotspot(null, null, false);
textBox1.Enabled = true;
textBox2.Enabled = true;
button1.Text = "Start";
connect = false;
}
}
6B. Coding Form1
private void Form1_Load(object sender, EventArgs e)
{
if (!IsAdmin())
{
RestartElevated();
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Hotspot(null, null, false);
Application.Exit();
}
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------
7.Setelah semua Coding dimasukkan, mulai running program. klik icon "➤" pada toolbar atau F5 pada keyboard.
-Masukkan SSID dan Password. kemudian klik tombol "Start".
-Jika ingin berhenti klik tombol "Berhenti".
8.
-Masuk ke Control Panel\Network and Internet\Network Connections pada laptop dan Enabled "Wifi Network Connections 2".
-Maka Hotspot telah tersambung otomatis pada laptop.
-Masukkan SSID dan Password jika menggunakan Smartphone.













