一个网站有多少g,北京代理记账公司排名前十强,朝阳区手机网站制作服务,上海私人网站建设最近在一直都在研究PC机硬件和软件相结合的软件#xff0c;硬件信息都是通过C与驱动结合获取。对于一个好久都没有接触C的人来说看这些东西太费劲了#xff0c;必须的重新捡一下C的基础知识#xff0c;必然也少不了C知识#xff0c;底层都是通过C与C结合#xff0c;提供接… 最近在一直都在研究PC机硬件和软件相结合的软件硬件信息都是通过C与驱动结合获取。对于一个好久都没有接触C的人来说看这些东西太费劲了必须的重新捡一下C的基础知识必然也少不了C知识底层都是通过C与C结合提供接口给J2EE调用J2EE也忘的一干二净了。从C那也了解到了AMT、ACPI、DPM等不少驱动的结合可以取到哪些硬件信息和对硬件操作有空就使用C#做了Demo不过还是使用C#比较得心应手。 这次是试验了一下网卡的Wake On Lan功能就是能够在广域网和局域网能远程启动目标机器需要网卡支持Wake on Lan功能关闭机器后网卡的灯会一直亮着还需要检查以下2点设置。 1. 进入BIOS设置Power-Automatic Power On里面设置Wake on LAN Enable/Automatic不同机器的BIOS设置位置不同找到对应的Wake on LAN选项设置就OK。 2. 进入网卡设置我的电脑-右键”管理“-设备管理器-网络适配器找到对应的网卡右键”属性“-电源管理勾选允许此设备唤醒计算机和子选项只允许幻数据包唤醒计算机”高级“选项卡里面检查属性里的唤醒幻数据包已启用 and 唤醒模式匹配已启用。 注不同的网卡设置可能会不一样 下面就用代码详细说明实现方式 #region WOL远程唤醒机器/// summary/// 通过WOL远程唤醒机器方法/// 摘要唤醒方法为网卡提供的魔术封包功能即以广播模式发送6个FF加上16遍目标机器MAC地址的字节数组/// /summary/// param namemac要唤醒机器的MAC/param/// param nameip要唤醒机器的子网掩码/param/// param nameportUDP消息发送端口/paramprivate static void WakeOnLan(string mac,string ip, int port){IPEndPoint point;UdpClient client new UdpClient();byte[] magicBytes GetMagicPacket(mac);point new IPEndPoint(IPAddress.Parse(ip), port);//广播模式:255.255.255.255try{int result client.Send(magicBytes, magicBytes.Length, point);}catch (SocketException ex) {throw new Exception(ex.ToString());}} /// summary/// 拼装MAC魔术封包/// /summary/// param namehexStringMAC地址字符串/param/// returns/returnspublic static byte[] GetMagicPacket(string macString){byte[] returnBytes new byte[102];string commandString FFFFFFFFFFFF;for (int i 0; i 6; i)returnBytes[i] Convert.ToByte(commandString.Substring(i * 2, 2), 16);byte[] macBytes StrToHexByte(macString);for (int i 6; i 102; i){returnBytes[i] macBytes[i % 6];}return returnBytes;}/// summary/// MAC地址字符串转16进制字节数组/// /summary/// param namehexStringMAC地址字符串/param/// returns/returnspublic static byte[] StrToHexByte(string hexString){hexString hexString.Replace(-, );if ((hexString.Length % 2) ! 0)hexString ;byte[] returnBytes new byte[hexString.Length / 2];for (int i 0; i returnBytes.Length; i)returnBytes[i] Convert.ToByte(hexString.Substring(i * 2, 2), 16);return returnBytes;}#endregion调用主函数 static void Main(string[] args){string macAddress, ipAddress;int port;Console.Write(Please input MAC:);macAddress Console.ReadLine();if (string.IsNullOrEmpty(macAddress)){macAddress F8-0F-41-21-12-68;Console.WriteLine(Default MAC: macAddress);}Console.Write(Please input Subnet:);ipAddress Console.ReadLine();if (string.IsNullOrEmpty(ipAddress)){ipAddress 255.255.255.255;Console.WriteLine(Default Subnet: ipAddress);}Console.Write(Please input Port:);if (!string.IsNullOrEmpty(Console.ReadLine())){port int.Parse(Console.ReadLine());}else{port 9000;Console.WriteLine(Default Port: port);}WakeOnLan(macAddress, ipAddress, port);Console.Read();}这个实例就介绍到这里吧欢迎大家来拍砖如有其它好的方法希望不要吝啬拿出来分享给大家一块学习进步 转载于:https://www.cnblogs.com/ZHF/p/3303082.html