CSDN博客

img wingfiring

远程唤醒源代码

发表于2004/7/1 13:18:00  1921人阅读

分类: C/C++

忘记出处了,留着自己用的。

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;

}

0 0

相关博文

我的热门文章

img
取 消
img