通过特定获取获取电脑外网IP地址
2024-08-29 14:43:39
void get_WanIp()
{ char Buf_File_Read[MAX_PATH] = {};
char IP_Temp[];
char IP_Host[];
int Result_URLDownloadToFile = ;
char szFilePath[MAX_PATH] = {};
GetTempPathA(MAX_PATH,szFilePath);
strcat(szFilePath,"IPinTheWorld.ini"); Result_URLDownloadToFile = URLDownloadToFileA(,"http://ip.dnsexit.com/index.php",szFilePath,,NULL);
if(Result_URLDownloadToFile != )//若URLDownloadToFile()成功,返回0
{
MessageBox(NULL, "网络故障,无法接入Internet,请联系网络管理员","提示",MB_ICONASTERISK);
return ;
} FILE *fp_Download_URL_File=NULL;
if ((fp_Download_URL_File=fopen( szFilePath,"r")) == NULL)
{
MessageBox(NULL, "系统故障,无法打开IP文件,请检查防火墙设置或联系管理人员","提示",MB_ICONASTERISK);
return ;
} if ( fp_Download_URL_File != NULL )
{
fseek(fp_Download_URL_File, , SEEK_SET);
fread(Buf_File_Read,,,fp_Download_URL_File);
fclose(fp_Download_URL_File);
DeleteFile(szFilePath);
}
strcpy(g_szWanIp,Buf_File_Read);
}
最新文章
- 序言<;EntityFramework6.0>;
- c# TCP Socket通讯基础
- 命名空间 - PHP笔记
- C++ 设计模式2 (面向对象设计原则)
- React History
- 排序算法——QuickSort、MergeSort、HeapSort(C++实现)
- 动态sql语句
- ASP.Net Core WebApi几种版本控制对比
- cesium编程入门(四)界面介绍及小控件隐藏
- 认识Java(2)
- ●BZOJ 4176 Lucas的数论
- node-服务器
- fdisk -l 参数详解
- 转载:【原译】Erlang性能的八个误区(Efficiency Guide)
- 高级Bash脚本编程(一)
- FineReport移动端如何获取地址位置
- Codeforces 950.E Data Center Maintenance
- nginx结合fastcgi
- msysgit: Unicode font warning
- Python ssh 远程执行shell命令