当前位置:网站首页>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
边栏推荐
- Penetration practice vulnhub range Keyring
- Countdownlatch blocking wait for multithreading concurrency
- Develop those things: easycvr cluster device management page function display optimization
- [wrung Ba wrung Ba is 20] [essay] why should I learn this in college?
- (12) About time-consuming printing
- Enter wechat applet
- transform. Forward and vector3 Differences in the use of forward
- DNS
- 目前炒期货在哪里开户最正规安全?怎么期货开户?
- Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
猜你喜欢

字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
![[Verilog quick start of Niuke network question brushing series] ~ priority encoder circuit ①](/img/24/23f6534e2c74724f9512c5b18661b6.png)
[Verilog quick start of Niuke network question brushing series] ~ priority encoder circuit ①

The new server is packaged with the source code of H5 mall with an operation level value of several thousand

From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl

Petrv2: a unified framework for 3D perception of multi camera images

In aks, use secret in CSI driver mount key vault

Euler function: find the number of numbers less than or equal to N and coprime with n
![[C language foundation] 12 strings](/img/42/9c024eb08eb935fe66c3aaac7589d8.jpg)
[C language foundation] 12 strings

Cookies and session keeping technology

Data warehouse (3) star model and dimension modeling of data warehouse modeling
随机推荐
Glidefast consulting was selected as the elite partner of servicenow in 2022
From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl
Euler function: find the number of numbers less than or equal to N and coprime with n
Product service, operation characteristics
New 95 community system whole station source code
Roewe rx5's "a little more" product strategy
New patent applications and transfers
Cookies and session keeping technology
中国茂金属聚乙烯(mPE)行业研究报告(2022版)
Setting up a time server requires the client to automatically synchronize the time of the server at 9 a.m. every day
两数之和c语言实现[通俗易懂]
How to use JMeter function and mockjs function in metersphere interface test
libcurl下载文件的代码示例
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
中国酶制剂市场预测与投资战略研究报告(2022版)
Cassette helicopter and alternating electric field magnetic manometer DPC
Data warehouse (3) star model and dimension modeling of data warehouse modeling
开发那些事儿:EasyCVR集群设备管理页面功能展示优化
Develop those things: easycvr cluster device management page function display optimization
[PHP foundation] realize the connection between PHP and SQL database