当前位置:网站首页>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
边栏推荐
- (16) ADC conversion experiment
- 存在安全隐患 起亚召回部分K3新能源
- ISO 27001 Information Security Management System Certification
- [splishsplash] about how to receive / display user parameters, MVC mode and genparam on GUI and JSON
- Is it safe to open a stock account by mobile phone? What do you need to bring with you to open an account?
- 开发那些事儿:EasyCVR集群设备管理页面功能展示优化
- New 95 community system whole station source code
- ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
- Unity3d extended toolbar
- 中国冰淇淋市场深度评估及发展趋势预测报告(2022版)
猜你喜欢

PETRv2:一个多摄像头图像3D感知的统一框架

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

在MeterSphere接口测试中如何使用JMeter函数和MockJS函数
Roewe rx5's "a little more" product strategy

New patent applications and transfers

Intelligent operation and maintenance practice: banking business process and single transaction tracking

Penetration practice vulnhub range Keyring

The difference and relationship between iteratible objects, iterators and generators
![[beauty detection artifact] come on, please show your unique skill (is this beauty worthy of the audience?)](/img/e8/f43f5583e330fbc0cb6c0188711707.jpg)
[beauty detection artifact] come on, please show your unique skill (is this beauty worthy of the audience?)
荣威 RX5 的「多一点」产品策略
随机推荐
线上开通ETF基金账户安全吗?有哪些步骤?
RadHat搭建内网YUM源服务器
Roewe rx5's "a little more" product strategy
What are the legal risks of NFT brought by stars such as curry and O'Neill?
Sword finger offer II 105 Maximum area of the island
[C supplement] [string] display the schedule of a month by date
Cassette helicopter and alternating electric field magnetic manometer DPC
PHP实现敏感词过滤系统「建议收藏」
【Try to Hack】vulnhub DC4
Setting up a time server requires the client to automatically synchronize the time of the server at 9 a.m. every day
中国一次性卫生用品生产设备行业深度调研报告(2022版)
In depth Research Report on China's disposable sanitary products production equipment industry (2022 Edition)
Is it safe to open a stock account by mobile phone? What do you need to bring with you to open an account?
Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
Common design parameters of solid rocket motor
String的trim()和substring()详解
GameFramework食用指南
ISO 27001 Information Security Management System Certification
Data warehouse (3) star model and dimension modeling of data warehouse modeling
Mysql database - Advanced SQL statement (2)