设为首页 加入收藏

TOP

ipconfig的C语言实现(三)
2014-11-24 08:24:44 来源: 作者: 【 】 浏览:4
Tags:ipconfig 语言 实现
DnsRecord;
int assignBuffLenght;
assignBuffLenght=(sizeof(DNS_RECORD))*Max;
pDnsRecord=(DNS_RECORD*)malloc(assignBuffLenght);
memset(pDnsRecord,0,assignBuffLenght);



if (WSAStartup(MAKEWORD(2,1),&wsaData)) //调用Windows Sockets DLL
{
printf("Winsock无法初始化!\n");
WSACleanup();

}

memset(hostname, 0, 256);
iRet = gethostname(hostname, sizeof(hostname));
if(iRet != 0 )
{
printf( "get hostname error:%d\n", iRet);
}
printf("%s\n", hostname);




LPSTR pOwnerName=hostname;


// Calling function DnsQuery to query Host or PTR records
status = DnsQuery(pOwnerName, //Pointer to OwnerName.
DNS_TYPE_A, //Type of the record to be queried.
DNS_QUERY_STANDARD, // Bypasses the resolver cache on the lookup.
NULL, //Contains DNS server IP address.
&pDnsRecord, //Resource record that contains the response.
NULL); //Reserved for future use.


// printf("The host name is %s \n",(pDnsRecord->Data.PTR.pNameHost));
while(pDnsRecord){
printf("The host name is %s \n",pDnsRecord->pName);
printf("the type is %d \n",pDnsRecord->wType);
printf("the lenght of data is %d \n", pDnsRecord->wDataLength);
printf(" the time to live is %d \n", pDnsRecord-> dwTtl);
printf("the lenght of data id %d \n", pDnsRecord-> dwReserved);


pDnsRecord=pDnsRecord->pNext;
}


printf("dnsCache print over");
}
else
{
printf("ilegal code");


}


}



void DoFlushDns(bool){



printf("relizing config/flushdns!");



}



首页 上一页 1 2 3 4 下一页 尾页 3/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C语言中函数传指针学习小结 下一篇Android中SQLite构造函数参数Cont..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Python 数据分析与可 (2025-12-26 21:51:20)
·从零开始学Python之 (2025-12-26 21:51:17)
·超长干货:Python实 (2025-12-26 21:51:14)
·为什么 Java 社区至 (2025-12-26 21:19:10)
·Java多线程阻塞队列 (2025-12-26 21:19:07)