远程唤醒源代码

类别:编程语言 点击:0 评论:0 推荐:


//IPAddress: 除去网络号后的IP段全部补255  ,如 210.45.234.255
 // MacAddress :  6个字节的字符型数组,每块网卡都有一个物理地址,在Window98中可以用
 //               winipcfg.exe 查询出来。

void TWakeUpOnLanForm:: WakeRemoteComputer(AnsiString IPAddress,unsigned char * MacAddress)
{
        unsigned char SendBuf[102];
        for( int i = 0; i < 102; i ++)
        {
                SendBuf[i] = (i < 6) ? 0xFF : MacAddress[i%6];
        }
        TMemoryStream * MemoryStream = new TMemoryStream();

        MemoryStream -> Clear();
        MemoryStream -> Write(SendBuf,102);
        NMUDP1 -> RemoteHost = IPAddress;   //除去网络号后的IP段全部补255
                                            //如 210.45.234.255
        NMUDP1 -> SendStream(MemoryStream);
        delete MemoryStream;

}

 

本文地址:http://com.8s8s.com/it/it29121.htm