当前位置:网站首页>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
边栏推荐
- Audio signal processing and coding - 2.5.3 the discrete cosine transform
- MFCC: Mel频率倒谱系数计算感知频率和实际频率转换
- [report] Microsoft: application of deep learning methods in speech enhancement
- JS calculation time difference
- Summary of several relationships of UML class diagram
- Virtual machine performance monitoring and fault handling tools
- 2021-2022-2 ACM集训队每周程序设计竞赛(8)题解
- 深度学习环境搭建步骤—gpu
- 音频编辑生成软件
- Prefer composition to inheritance
猜你喜欢
Pdf reference learning notes
Lottery applet, mother no longer have to worry about who does the dishes (assign tasks), so easy
Virtual machine performance monitoring and fault handling tools
Esp8266 - beginner level Chapter 1
An idea of rendering pipeline based on FBO
White screen processing method of fulter startup page
No, some people can't do the National Day avatar applet (you can open the traffic master and earn pocket money)
MySQL syntax collation
指针数组与数组指针的区分
Use of fluent custom fonts and pictures
随机推荐
[report] Microsoft: application of deep learning methods in speech enhancement
Class loading mechanism
Coordinate conversion WGS-84 to gcj-02 and gcj-02 to WGS-84
No, some people can't do the National Day avatar applet (you can open the traffic master and earn pocket money)
Openlayers 5.0 reload the map when the map container size changes
Openlayers 5.0 discrete aggregation points
MFC获取本机IP(网络通讯时用得多)
[report] Microsoft: application of deep learning methods in speech enhancement
The platinum library cannot search the debug process records of some projection devices
Virtual machine performance monitoring and fault handling tools
An example of using JNI to directly access surface data
HTTP cache - HTTP authoritative guide Chapter VII
MySQL syntax collation
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
Golang timer
MySQL syntax collation (3)
Codeworks round 783 (Div. 2) d problem solution
A brief explanation of golang's keyword "competence"
Openlayers draw rectangle
Matlab 2019 installation of deep learning toolbox model for googlenet network