基本信息
源码名称:c++ IP地址修改源码(更换ip地址)
源码大小:0.14M
文件格式:.zip
开发语言:C/C++
更新时间:2017-04-25
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 3 元×
微信扫码支付:3 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
// IP_changerDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "IP_changer.h"
#include "IP_changerDlg.h"
#include "afxdialogex.h"
#include <string.h>
#include <winsock2.h>
#include <setupapi.h>
#define UnknownDevice TEXT("<Unknown Device>")
#pragma comment(lib, "ws2_32.lib")
#pragma comment (lib,"setupapi")
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
using namespace std;
#define MAXNUM 20
#define MAXLEN 10000
//全局数据和函数声明区
ADAPTER_INFO AdapterInfoVector[MAXNUM];
int CurrentNum=0;
HDEVINFO hDevInfo = 0;
static int flag=0;
bool StateChange(DWORD NewState,DWORD SelectedItem,HDEVINFO hDevInfo);
bool stringcmp(char *base,char *des);
void GetFileName(int index,CString& fileName);
void AdatperInfoToIPConfInfo(const ADAPTER_INFO adatperinfo,IPConfigInfo& ipconf);
// CIP_changerDlg 对话框
CIP_changerDlg::CIP_changerDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CIP_changerDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_AdapterNum=0;
m_InitIndex=0;
}
void CIP_changerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO1, m_adapter);
}
BEGIN_MESSAGE_MAP(CIP_changerDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDOK, &CIP_changerDlg::OnBnClickedOk)
ON_CBN_SELCHANGE(IDC_COMBO1, &CIP_changerDlg::OnCbnSelchangeCombo1)
END_MESSAGE_MAP()
// CIP_changerDlg 消息处理程序
BOOL CIP_changerDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
//初始化网卡信息,添加到复选框
GetAdapterInfo();
for(int i=0;i<m_AdapterNum;i )
{
m_adapter.InsertString(i,AdapterInfoVector[i].strDriverDesc);
}
m_adapter.SetCurSel(0);
m_adapter.SetDroppedWidth(290);
//显示当前复选框中的Adapter的IP信息
DisplayAdapterInfo(AdapterInfoVector[0]);
//如果配置文件不存在,则创建配置文件
CString fileName,FileContent;
for(int i=0;i<m_AdapterNum;i )
{
GetFileName(i,fileName);
CreateConfigFile(fileName,AdapterInfoVector[i]);
}
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
// 这将由框架自动完成。
void CIP_changerDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon 1) / 2;
int y = (rect.Height() - cyIcon 1) / 2;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR CIP_changerDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
bool CIP_changerDlg::RegSetIP(LPCTSTR lpszAdapterName, int nIndex, LPCTSTR pIPAddress, LPCTSTR pNetMask, LPCTSTR pNetGate,LPCTSTR pNameServer)
{
HKEY hKey;
CString strKeyName ="SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
strKeyName = lpszAdapterName;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
strKeyName,
0,
KEY_WRITE,
&hKey) != ERROR_SUCCESS)
return FALSE;
char mszIPAddress[100]={0};
char mszNetMask[100]={0};
char mszNetGate[100]={0};
char mszNameServer[100]={0};
char buf[100];
strncpy(mszIPAddress,pIPAddress, 98);
strncpy(mszNetMask,pNetMask, 98);
strncpy(mszNetGate, pNetGate, 98);
strncpy(mszNameServer,pNameServer,98);
int nIP, nMask, nGate,nServer;
nIP = strlen(mszIPAddress);
nMask = strlen(mszNetMask);
nGate = strlen(mszNetGate);
nServer= strlen(mszNameServer);
*(mszIPAddress nIP 1) = 0x00;
nIP = 2;
*(mszNetMask nMask 1) = 0x00;
nMask = 2;
*(mszNetGate nGate 1) = 0x00;
nGate = 2;
*(mszNameServer nServer 1) = 0x00;
nServer = 2;
if(RegSetValueEx(hKey, TEXT("IPAddress"), 0, REG_MULTI_SZ, (unsigned char*)mszIPAddress, nIP))
return(false);
if(RegSetValueEx(hKey, TEXT("SubnetMask"), 0, REG_MULTI_SZ, (unsigned char*)mszNetMask, nMask))
return(false);
RegSetValueEx(hKey, TEXT("DefaultGateway"), 0, REG_MULTI_SZ, (unsigned char*)mszNetGate, nGate);
RegSetValueEx(hKey, TEXT("NameServer"), 0, REG_SZ, (unsigned char*)mszNameServer, nServer);
RegCloseKey(hKey);
return(true);
}
bool CIP_changerDlg::GetAdapterInfo()
{
HKEY hKey,hSubKey,hNdiKey,hNdiIntKey;
//打开注册表
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\Control\\Class\\{4d36e972-e325-11ce-bfc1-08002be10318}",\
0,KEY_READ,&hKey)!=ERROR_SUCCESS)
return FALSE;
DWORD dwIndex = 0;
DWORD dwBufSize = 256;
DWORD dwDataType;
char szSubKey[256]={0};
unsigned char szData[256]={0};
int flag=0;
int temp=0;
//先把适配器信息结构体数组AdapterInfoVector清空
for(int i=0;i<MAXNUM;i )
{
AdapterInfoVector[i].strDriverDesc.Empty();
AdapterInfoVector[i].strIP.Empty();
AdapterInfoVector[i].strName.Empty();
AdapterInfoVector[i].strNameServer.Empty();
AdapterInfoVector[i].strNetGate.Empty();
AdapterInfoVector[i].strNetMask.Empty();
}
m_AdapterNum=0;
int i_num=0;
//把所有适配器当前配置信息存入AdapterInfoVector中
while(RegEnumKeyEx(hKey,dwIndex ,szSubKey,&dwBufSize,NULL,NULL,NULL,NULL)==ERROR_SUCCESS)
{
if(RegOpenKeyEx(hKey,szSubKey,0,KEY_READ,&hSubKey)==ERROR_SUCCESS)
{
int find=0;
if(RegOpenKeyEx(hSubKey,"Ndi",0,KEY_READ,&hNdiKey)==ERROR_SUCCESS)
{
dwBufSize=256;
if(RegQueryValueEx(hNdiKey,"Service",0,&dwDataType,szData,&dwBufSize)==ERROR_SUCCESS)
{
//判断虚拟网卡
if(strcmp((char*)szData,"VMnetAdapter")==0)
find=1;
else if(RegOpenKeyEx(hSubKey,"Ndi\\Interfaces",0,KEY_READ,&hNdiIntKey)==ERROR_SUCCESS)
{
dwBufSize=256;
if(RegQueryValueEx(hNdiIntKey,"LowerRange",0,&dwDataType,szData,&dwBufSize)==ERROR_SUCCESS)
{
//判断是不是以太网卡
if(stringcmp("ethernet",(char*)szData)==0)
{
flag=1;
find=1;
}//判断是不是无线网卡
else if(strcmp("ethernet",(char*)szData)==TRUE)
find=1;
}
RegCloseKey(hNdiIntKey);
}
RegCloseKey(hNdiKey);
}
if(!find)//只写入网卡信息
{
dwBufSize=256;
if(RegQueryValueEx(hSubKey,"DriverDesc",0,&dwDataType,szData,&dwBufSize)==ERROR_SUCCESS)
{
ADAPTER_INFO pAI;
pAI.strDriverDesc.Format("%s",szData);
dwBufSize = 256;
if(RegQueryValueEx(hSubKey, "NetCfgInstanceID", 0, &dwDataType, szData, &dwBufSize) == ERROR_SUCCESS)
{
pAI.strName.Format(_T("%s"),szData);
RegGetIp(pAI, (LPCTSTR)szData);
}
AdapterInfoVector[m_AdapterNum ]=pAI;// 加入到容器中
if(flag==1)
{
m_InitIndex=m_AdapterNum-1;
flag=0;
}
}
}
RegCloseKey(hSubKey);
}
}
dwBufSize = 256;
}
RegCloseKey(hKey);
return TRUE;
}
void CIP_changerDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
CString IPAddrStr,SubMaskStr,DefGateWayStr,DnsStr;
GetDlgItem(IDC_IPADDRESS_IP)->GetWindowTextA(IPAddrStr);
GetDlgItem(IDC_IPADDRESS_SUBMASK)->GetWindowTextA(SubMaskStr);
DefGateWayStr.Empty();//为空
DnsStr.Empty();//为空
// GetDlgItem(IDC_STCIP_GATEWAY)->GetWindowText(DefGateWayStr);
// GetDlgItem(IDC_STCIP_DNS)->GetWindowText(DnsStr);
// AfxMessageBox(IPAddrStr SubMaskStr);
//把当前IP的信息写入注册表中
// if(RegSetIP(AdapterInfoVector[m_adapter.GetCurSel()].strName,0,IPAddrStr,SubMaskStr,DefGateWayStr,DnsStr))
if(!RegSetIP(AdapterInfoVector[m_adapter.GetCurSel()].strName,0,IPAddrStr,SubMaskStr,DefGateWayStr,DnsStr))
{
MessageBox(_T("IP配置成功写入注册表失败"));
}
else//若写入,则更新数据,用于更新配置文件
{
AdapterInfoVector[m_adapter.GetCurSel()].strIP=IPAddrStr;
AdapterInfoVector[m_adapter.GetCurSel()].strNetMask=SubMaskStr;
AdapterInfoVector[m_adapter.GetCurSel()].strNetGate=DefGateWayStr;
AdapterInfoVector[m_adapter.GetCurSel()].strNameServer=DnsStr;
}
//重启网卡
int ret1=ChangeAdapterStatus(AdapterInfoVector[m_adapter.GetCurSel()].strDriverDesc,DICS_DISABLE);
int ret2=ChangeAdapterStatus(AdapterInfoVector[m_adapter.GetCurSel()].strDriverDesc,DICS_ENABLE);
if(ret1==TRUE&&ret2==TRUE)
;
// MessageBox(_T("IP更改操作成功"));
else
{
MessageBox(_T("IP更改操作失败"));
return ;
}
//如果配置文件不存在,则创建配置文件
CString fileName,FileContent;
for(int i=0;i<m_AdapterNum;i )
{
GetFileName(i,fileName);
CreateConfigFile(fileName,AdapterInfoVector[i]);
}
}
//从注册表中获得lpszAdapterName的IP配置信息
/////////////////////////////////////////////////////////////////////////////
//bool CIP_changerDlg::RegGetIp(ADAPTER_INFO& pAI, LPCTSTR lpszAdapterName, int nIndex)
bool CIP_changerDlg::RegGetIp(ADAPTER_INFO& pAI, LPCTSTR lpszAdapterName)
{
HKEY hKey;
CString strKeyName = _T("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\");
strKeyName = lpszAdapterName;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
strKeyName,
0,
KEY_READ,
&hKey) != ERROR_SUCCESS)
return FALSE;
unsigned char szData[256];
DWORD dwDataType, dwBufSize;
dwBufSize = 256;
if(RegQueryValueEx(hKey, _T("IPAddress"), 0, &dwDataType, szData, &dwBufSize) == ERROR_SUCCESS)
pAI.strIP.Format(_T("%s"),szData);
dwBufSize = 256;
if(RegQueryValueEx(hKey, _T("SubnetMask"), 0, &dwDataType, szData, &dwBufSize) == ERROR_SUCCESS)
pAI.strNetMask.Format(_T("%s"),szData);
dwBufSize = 256;
if(RegQueryValueEx(hKey, _T("DefaultGateway"), 0, &dwDataType, szData, &dwBufSize) == ERROR_SUCCESS)
pAI.strNetGate.Format(_T("%s"),szData);
dwBufSize = 256;
if(RegQueryValueEx(hKey, _T("NameServer"), 0, &dwDataType, szData, &dwBufSize) == ERROR_SUCCESS)
pAI.strNameServer.Format(_T("%s"),szData);
RegCloseKey(hKey);
return TRUE;
}
bool CIP_changerDlg::ChangeAdapterStatus(LPCTSTR AdapterDeviceDesc, int Flag)//Flag =DICS_DISABLE-->禁用网络
{ //Flag =DICS_ENABLE--->恢复网络
if (INVALID_HANDLE_VALUE == (hDevInfo =
SetupDiGetClassDevs(NULL,NULL,0,
DIGCF_PRESENT|DIGCF_ALLCLASSES)))
{
AfxMessageBox(_T("GetClassDevs"));
}
DWORD i;
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
unsigned char *guid[4]={0};
char DeviceName[200]={0};
wchar_t str[100]={0};
int size=100;
DWORD DataT;
unsigned char *buffer=NULL;
DWORD sz=0;
for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i,&DeviceInfoData);i )
{
//DeviceInfoData.ClassGuid="{4D36E972-E325-11CE-BFC1-08002BE10318}";
StringFromGUID2(DeviceInfoData.ClassGuid,str,size);
char temp[100]={0};
char Rtl[]="{4D36E972-E325-11CE-BFC1-08002BE10318}";
for(int j=0;str[j]!='\0';j )
{
temp[j]=(char)str[j];
}
if(strcmp(temp,Rtl)==0)
{
LPTSTR buffer=NULL ;
DWORD buffersize=0 ;
while(!SetupDiGetDeviceRegistryProperty(hDevInfo,&DeviceInfoData,\
SPDRP_DEVICEDESC,&DataT, (PBYTE)buffer,buffersize,&buffersize))
{
if(GetLastError()==ERROR_INVALID_DATA)
{
break ;
}
else if(GetLastError()==ERROR_INSUFFICIENT_BUFFER)
{
if(buffer)
LocalFree(buffer);
buffer=(LPTSTR)LocalAlloc(LPTR,buffersize);
}
else
{
SetupDiDestroyDeviceInfoList(hDevInfo);
return FALSE ;
}
}
if(GetLastError()==ERROR_INVALID_DATA)
continue ;
if(strcmp(buffer,AdapterDeviceDesc)==0)
{
if (StateChange(Flag,i,hDevInfo))
{
break;
}
else
{
CString temp=_T("对");
temp =AdapterDeviceDesc;
temp =_T("的操作失败!");
AfxMessageBox(temp);
return FALSE;
}
}
}
}
return TRUE;
}
bool StateChange(DWORD NewState, DWORD SelectedItem,HDEVINFO hDevInfo)
{
LPTSTR buffer=NULL ;
DWORD buffersize=0 ;
SP_PROPCHANGE_PARAMS PropChangeParams = {sizeof(SP_CLASSINSTALL_HEADER)};
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
HCURSOR hCursor;
//
// This may take a while :^(
//
hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
//
// Get a handle to the Selected Item.
//
if (!SetupDiEnumDeviceInfo(hDevInfo,SelectedItem,&DeviceInfoData))
{
printf("EnumDeviceInfo");
return FALSE;
}
//{4D36E972-E325-11CE-BFC1-08002BE10318}
// Set the PropChangeParams structure.
//
PropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
PropChangeParams.Scope = DICS_FLAG_GLOBAL;
PropChangeParams.StateChange = NewState;
if (!SetupDiSetClassInstallParams(hDevInfo,
&DeviceInfoData,
(SP_CLASSINSTALL_HEADER *)&PropChangeParams,
sizeof(PropChangeParams)))
{
printf("SetClassInstallParams");
SetCursor(hCursor);
return FALSE;
}
//
// Call the ClassInstaller and perform the change.
//
if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,
hDevInfo,
&DeviceInfoData))
{
printf("SetClassInstallParams");
SetCursor(hCursor);
return TRUE;
}
return TRUE;
}
//////////////////////////////////////////////////////////
//如果des中有一子串和base相同,则返回true,否则返回false
//////////////////////////////////////////////////////////
bool stringcmp(char *base,char *des)
{
int baselen=strlen(base);
int deslen=strlen(des);
char temp[9]={0};
int i=0;
int flag=0;
memset(temp,0,strlen(temp));
for(i=0;i<=(deslen-baselen);i )
{
strncpy(temp,des i,baselen);
if(strcmp(base,temp)==0)
{
flag=1;
break;
}
}
if(flag)
return TRUE;
else
return FALSE;
}
void CIP_changerDlg::DisplayAdapterInfo(const ADAPTER_INFO adapterinfo)
{
GetDlgItem(IDC_IPADDRESS_IP)->SetWindowText(adapterinfo.strIP);
GetDlgItem(IDC_IPADDRESS_SUBMASK)->SetWindowText(adapterinfo.strNetMask);
// GetDlgItem(IDC_STCAP_GATEWAY)->SetWindowText(adapterinfo.strNetGate);
// GetDlgItem(IDC_STCAP_DNS)->SetWindowText(adapterinfo.strNameServer);
}
void GetFileName(int index,CString& fileName)
{
fileName.Format("%s%d%s","Adapter",index,".config");
}
void CIP_changerDlg::CreateConfigFile(const CString fileName,const ADAPTER_INFO adatperinfo)
{
IPConfigInfo ipconf;
CFileFind ff;
if(ff.FindFile(fileName))//移除文件
{
ff.Close();
CFile::Remove(fileName);
}
CFile file(fileName,CFile::modeCreate);//重新创建文件
IPConfigInfo temp;
file.Close();
AdatperInfoToIPConfInfo(adatperinfo,ipconf);
CFile file_w;
CString fileContent;
if(file_w.Open(fileName,CFile::modeNoTruncate|CFile::modeWrite)==0)
{
AfxMessageBox(_T("打开文件错误"));
return;
}
fileContent =ipconf.IPAddr;
fileContent ="/";
fileContent =ipconf.SubMask;
fileContent ="/";
fileContent =ipconf.DefGateway;
fileContent ="/";
fileContent =ipconf.NameServer;
fileContent ="#";
file_w.SeekToEnd();
file_w.Write(fileContent,fileContent.GetLength());
file_w.Close();
}
/*
void CIP_changerDlg::CreateConfigFile(const CString fileName,const ADAPTER_INFO adatperinfo)
{
CFileFind ff;
if(ff.FindFile(fileName))
{
ff.Close();
CFile::Remove(fileName);
}
CFile file(fileName,CFile::modeCreate);
IPConfigInfo temp;
file.Close();
AdatperInfoToIPConfInfo(adatperinfo,temp);
WrtieIPconfToFile(fileName,temp);
}
*/
void AdatperInfoToIPConfInfo(const ADAPTER_INFO adatperinfo,IPConfigInfo& ipconf)
{
ipconf.IPAddr=adatperinfo.strIP;
ipconf.SubMask=adatperinfo.strNetMask;
ipconf.DefGateway=adatperinfo.strNetGate;
ipconf.NameServer=adatperinfo.strNameServer;
}
void CIP_changerDlg::OnCbnSelchangeCombo1()//点击下拉列表时的响应函数
{
// TODO: 在此添加控件通知处理程序代码
CString FileContent,fileName,IPStr,temp;
IPConfigInfo IPConf;
int i=0,j=0,len;
//刷新适配器显示列表
DisplayAdapterInfo(AdapterInfoVector[m_adapter.GetCurSel()]);
//刷新IP地址显示列表
GetFileName(m_adapter.GetCurSel(),fileName);
ReadFileToString(fileName,FileContent);
GetIPAddrFromString(FileContent,IPStr);
if(IPStr.GetLength()>1)//读取文件IP地址和子网掩码
{
len=IPStr.GetLength();
// m_ipAddr.ResetContent();
while(i<len)
{
temp.Empty();
for(;IPStr.GetAt(i)!='#';i )
temp =IPStr.GetAt(i);
j ;
i ;
}
IPStr.Empty();
IPStr=temp;//恢复对应IP
// m_ipAddr.GetLBText(m_ipAddr.GetCurSel(),IPStr);
GetIPConfigFromString(IPStr,FileContent,IPConf);
DisplayIPConfInfo(IPConf);
}
else
{
IPConfigInfo IPConf;
// m_ipAddr.ResetContent();
DisplayIPConfInfo(IPConf);
MessageBox("该网卡没有配置IP信息");
}
}
void CIP_changerDlg::GetIPConfigFromString(const CString IPStr,const CString str,IPConfigInfo& IPConf)
{
int i=0,j=0,pos=str.Find(IPStr);
int len=str.GetLength();
IPConf.IPAddr=IPStr;
for(;str.GetAt(pos)!='/';pos );
pos ;
for(;str.GetAt(pos)!='/';pos )
IPConf.SubMask =str.GetAt(pos);
pos ;
for(;str.GetAt(pos)!='/';pos )
IPConf.DefGateway =str.GetAt(pos);
pos ;
for(;str.GetAt(pos)!='#';pos )
IPConf.NameServer =str.GetAt(pos);
}
void CIP_changerDlg::DisplayIPConfInfo(const IPConfigInfo IPconf)
{
GetDlgItem(IDC_IPADDRESS_IP)->SetWindowText(IPconf.IPAddr);
GetDlgItem(IDC_IPADDRESS_SUBMASK)->SetWindowText(IPconf.SubMask);
// GetDlgItem(IDC_STCIP_GATEWAY)->SetWindowText(IPconf.DefGateway);
// GetDlgItem(IDC_STCIP_DNS)->SetWindowText(IPconf.NameServer);
}
bool CIP_changerDlg::ReadFileToString(const CString fileName, CString &contentStr)
{
CFile file;
if(file.Open(fileName,CFile::modeRead)==0)
{
MessageBox(_T("读取文件失败"));
return FALSE;
}
char content[MAXLEN];
int len=file.Read(content,MAXLEN);
content[len]='\0';
contentStr.Format("%s",content);
file.Close();
if(contentStr.IsEmpty())
{
CString temp;
temp =fileName;
temp ="文件为空,请点击“添加IP项”添加配置信息";
MessageBox(temp);
return FALSE;
}
return TRUE;
}
/////////////////////////////////////////////////////////////////
//得到contentStr中的所有IP地址
///////////////////////////////////////////////////////////////////
void CIP_changerDlg::GetIPAddrFromString(const CString str, CString &IPStr)
{
int i=0,j=0;
int len=str.GetLength();
while(j<len)
{
if(i==0||str.GetAt(i)=='#')
{
while(i<len&&str.GetAt(i)!='/')
{
IPStr =str.GetAt(i);
i ;
}
}
for(;i<len&&str.GetAt(i)!='#';i )
;
j=i;
}
}