How can I get connected wifi password in my code C#

…衆ロ難τιáo~ 提交于 2019-12-11 17:08:17

问题


I make a program where when I copy "WiFi status". I get a windows notification containing the ssid and the singular strength. Now I also want the option to get the WiFi password, but I don't know how to do that. Will someone help me with that?

This is my code:

            if (clipboardText == "wifi status")
            {

                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                p.StartInfo.FileName = "netsh.exe";
                p.StartInfo.Arguments = "wlan show interfaces";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.Start();

                string s = p.StandardOutput.ReadToEnd();
                string s1 = s.Substring(s.IndexOf("SSID"));
                s1 = s1.Substring(s1.IndexOf(":"));
                s1 = s1.Substring(2, s1.IndexOf("\n")).Trim();

                string s2 = s.Substring(s.IndexOf("Signal"));
                s2 = s2.Substring(s2.IndexOf(":"));
                s2 = s2.Substring(2, s2.IndexOf("\n")).Trim();
                {
                    notifyIcon1.Icon = SystemIcons.Exclamation;
                    notifyIcon1.BalloonTipTitle = "";
                    notifyIcon1.BalloonTipText = "WIFI verbonden met " + s1 + "  " + "Signaal sterkte " + s2;
                    notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
                    notifyIcon1.ShowBalloonTip(1000);
                }
            }

来源:https://stackoverflow.com/questions/58039148/how-can-i-get-connected-wifi-password-in-my-code-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!