|
我用的evc里带的那个wince模拟器,我想得到wince模拟器的ip。用了下面的程序,只显示了name但不能显示ip怎么回事啊。
void CCxView::OnDraw(CDC* pDC)
{
CCxDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
char name[256];
gethostname(name,50);
CString strName;
strName = name;
pDC->DrawText(strName,CRect(10,30,200,50),DT_LEFT);
CString sIp;
HOSTENT* host=::gethostbyname((char*)strName.GetBuffer(strName.GetLength()));
PBYTE addrList =(PBYTE)host->h_addr_list[0];
sIp.Format(_T("%d.%d"),addrList[0],addrList[1],
addrList[2],addrList[3]);
pDC->DrawText(sIp,CRect(10,30,100,50),DT_LEFT);
}
|
|