当前位置:网站首页>MFC obtains local IP (used more in network communication)
MFC obtains local IP (used more in network communication)
2022-07-01 17:47:00 【ToneSole】
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
边栏推荐
- (28) Shape matching based on contour features
- Why should you consider using prism
- Oom caused by improper use of multithreading
- Cookies and session keeping technology
- 中国超高分子量聚乙烯产业调研与投资前景报告(2022版)
- Code example of libcurl download file
- 深度优先遍历和广度优先遍历[通俗易懂]
- (16) ADC conversion experiment
- 多线程使用不当导致的 OOM
- SQL injection vulnerability (MySQL and MSSQL features)
猜你喜欢

Data warehouse (3) star model and dimension modeling of data warehouse modeling
Roewe rx5's "a little more" product strategy
![[PHP foundation] realize the connection between PHP and SQL database](/img/eb/c8953eddfe3b19b0adb5529957d275.jpg)
[PHP foundation] realize the connection between PHP and SQL database

Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse

Length of learning and changing

June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries

An example of data analysis of an old swatch and an old hard disk disassembly and assembly combined with the sensor of an electromagnetic press

整形数组合并【JS】

Detailed explanation of string's trim() and substring()

vulnhub靶场-Hacker_Kid-v1.0.1
随机推荐
Research Report on development monitoring and investment prospects of China's smart environmental protection industry (2022 Edition)
徽商期货是正规期货平台吗?在徽商期货开户安全吗?
(12) About time-consuming printing
Intel's open source deep learning tool library openvino will increase cooperation with local software and hardware parties and continue to open
China biodegradable plastics market forecast and investment strategy report (2022 Edition)
期货先锋这个软件正规吗安全吗?选择哪家期货公司更安全?
DRF --- response rewrite
中国乙腈市场预测与战略咨询研究报告(2022版)
官宣!香港科技大学(广州)获批!
Openlayers customize bubble boxes and navigate to bubble boxes
整形数组合并【JS】
Irradiance, Joule energy, exercise habits
(十七)DAC转换实验
PHP实现敏感词过滤系统「建议收藏」
There is a new breakthrough in quantum field: the duration of quantum state can exceed 5 seconds
Blackwich: the roadmap of decarbonization is the first step to realize the equitable energy transformation in Asia
PIP version problems: PIP problems still occur when installing akshare and using Tsinghua source and Douban source
vulnhub靶场-hacksudo - Thor
New 95 community system whole station source code
Is the software of futures pioneer formal and safe? Which futures company is safer to choose?