当前位置:网站首页>MFC obtains local IP (used more in network communication)
MFC obtains local IP (used more in network communication)
2022-04-23 19:29:00 【ToneChip】
CString CUDPDlg::GetIP() // Access to the local IP
{
WORD wVersionRequested;
WSADATA wsaData;
char name[255]; // Local hostname array variable
CString m_ip; // IP Address string variable
PHOSTENT hostinfo; // hostent Structure pointer
wVersionRequested = MAKEWORD(2, 0); // Connecting applications to winsock Dll
if (WSAStartup(wVersionRequested, &wsaData) == 0)
{
if (gethostname(name, sizeof(name)) == 0) // Get the local host name
{
if ((hostinfo = gethostbyname(name)) != NULL) // Get host information
{
m_ip = inet_ntoa(*(struct in_addr *)*hostinfo->h_addr_list); // Convert to get IP Address
}
else m_ip = "IP Detection failed ";
}
WSACleanup(); // suspend winsock DLL Use
}
return m_ip; // return IP Address string
}
Call the following
CString localIP;
localIP = GetIP(); // Get this machine IP
SetDlgItemText(IDC_IP1, localIP); // Get local IP Display to the interface
版权声明
本文为[ToneChip]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231923488465.html
边栏推荐
- Pdf reference learning notes
- 2021-2022-2 ACM training team weekly Programming Competition (8) problem solution
- 对普通bean进行Autowired字段注入
- MySQL practical skills
- LPC1768 关于延时Delay时间与不同等级的优化对比
- 数据分析学习目录
- Garbage collector and memory allocation strategy
- Data analysis learning directory
- Kubernetes入门到精通-在 Kubernetes 上安装 OpenELB
- Openlayers 5.0 reload the map when the map container size changes
猜你喜欢

Use of fluent custom fonts and pictures

【webrtc】Add x264 encoder for CEF/Chromium

The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch

Kubernetes入门到精通-KtConnect(全称Kubernetes Toolkit Connect)是一款基于Kubernetes环境用于提高本地测试联调效率的小工具。

NiO related Basics

山大网安靶场实验平台项目—个人记录(四)

Esp8266 - beginner level Chapter 1

Scrum Patterns之理解各种团队模式

MySQL syntax collation

Prefer composition to inheritance
随机推荐
Data analysis learning directory
C学习完结
Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
ArcMap publishing slicing service
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
arcMap 发布切片服务
Problems caused by flutter initialroute and home
The flyer realizes page Jump through routing routes
MySQL syntax collation (5) -- functions, stored procedures and triggers
指针数组与数组指针的区分
Use of fluent custom fonts and pictures
White screen processing method of fulter startup page
openlayers 5.0 热力图
SQL of contention for system time plus time in ocrale database
FFT物理意义: 1024点FFT就是1024个实数,实际进入fft的输入是1024个复数(虚部为0),输出也是1024个复数,有效的数据是前512个复数
Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
MySQL lock
Openlayers 5.0 thermal diagram
A brief explanation of golang's keyword "competence"
Kubernetes入门到精通-在 Kubernetes 上安装 OpenELB