110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Diagnostics;
namespace WifiTest
{
class Program
{
static void Main(string[] args)
{
Process proc = new Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.FileName = "netsh";
proc.StartInfo.Arguments = "wlan show networks mode=bssid";
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
Console.WriteLine(output);
Console.Read();
}
}
}
public static uint GetSignalQuality(Guid gg)
{
UInt32 dwSize = 0;
IntPtr ppData = IntPtr.Zero;
IntPtr ppChannel = IntPtr.Zero;
WLAN_OPCODE_VALUE_TYPE pOpcodeValueType;
if (WlanQueryInterface(m_pClientHandle, ref gg,
WLAN_INTF_OPCODE.wlan_intf_opcode_current_connection,
IntPtr.Zero, out dwSize, out ppData,
out pOpcodeValueType) != ERROR_SUCCESS)
{
m_errorMessage = "Failed WlanQueryInterface() - " +
"Current Connection Attributes";
return 0;
}
if (ppData != IntPtr.Zero)
{
WLAN_CONNECTION_ATTRIBUTES connectionAttributes =
new WLAN_CONNECTION_ATTRIBUTES(ppData);
return connectionAttributes.wlanAssociationAttributes.wlanSignalQuality;
}
return 0;
}