⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wlan configuratordlg.cpp

📁 WINCE环境下
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		  GetDlgItem(IDC_STATIC5)->EnableWindow();	// 使能 groupbox
		  GetDlgItem(IDC_RADIO8)->EnableWindow();// 使能单选框
		  GetDlgItem(IDC_RADIO9)->EnableWindow();// 使能单选框
		  authen = 1;							// 设置标志位
	}
	else
	{
		  GetDlgItem(IDC_STATIC5)->EnableWindow(FALSE); //变灰
		  GetDlgItem(IDC_RADIO8)->EnableWindow(FALSE);//变灰
		  GetDlgItem(IDC_RADIO9)->EnableWindow(FALSE);//变灰
		  authen = 0;									// 设置标志位
		  c.Empty();										// 清空字符串
	}

	
}

void CWLANConfiguratorDlg::OnCheck1() 
{
	// TODO: Add your control notification handler code here
	int iCheck1;   
	int iCheck11;
	iCheck1 = (int)SendDlgItemMessage(IDC_CHECK1, BM_GETCHECK, 0, 0); // WEP 复选框选中判断
	iCheck11 = (int)SendDlgItemMessage(IDC_RADIO11, BM_GETCHECK, 0, 0);// WEP 中yes 单选框选中判断
	/// 判断wep复选框是否为选中
	if (iCheck1)
	{
		  GetDlgItem(IDC_STATIC6)->EnableWindow();// 使能 groupbox
		  GetDlgItem(IDC_RADIO10)->EnableWindow();// 使能单选框
		  GetDlgItem(IDC_RADIO11)->EnableWindow();// 使能单选框
		  wep = 1;									// 设置标志位
		  if(iCheck11)								// 判断wep yes 单选框是否为选中
		  {
			  GetDlgItem(IDC_STATIC3)->EnableWindow(); // 使能 groupbox
			  GetDlgItem(IDC_EDIT2)->EnableWindow(); // 使能单选框
		  
		  }

	}
	else
	{
		  GetDlgItem(IDC_STATIC6)->EnableWindow(FALSE);//变灰
		  GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);//变灰
		  GetDlgItem(IDC_STATIC3)->EnableWindow(FALSE);//变灰
		  GetDlgItem(IDC_RADIO10)->EnableWindow(FALSE);//变灰
		  GetDlgItem(IDC_RADIO11)->EnableWindow(FALSE);//变灰
		  wep = 0;									// 设置标志位
		  d.Empty();										// 清空字符串
		  e.Empty();										// 清空字符串
		  m_key.Empty();	//m_key为窗口IDC_EDIT2 字符变量,清空字符串
		  UpdateData(false);


	}

	
}

void CWLANConfiguratorDlg::OnRadio10() 
{
	// TODO: Add your control notification handler code here
	///wep groupbox 中 "NO"单选框选中设置

		  GetDlgItem(IDC_STATIC3)->EnableWindow(FALSE);//变灰
		  GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);//变灰
		  m_key.Empty();				// 清空字符串
		  UpdateData(false);


}

void CWLANConfiguratorDlg::OnRadio11() 
{
	// TODO: Add your control notification handler code here
	///wep groupbox 中 "yes"单选框选中设置
	int iCheck1;
	iCheck1 = (int)SendDlgItemMessage(IDC_CHECK1, BM_GETCHECK, 0, 0);
	/// 判断wep复选框是否为选中
	if (iCheck1)
		{

		  GetDlgItem(IDC_STATIC3)->EnableWindow();// 使能groupbox
		  GetDlgItem(IDC_EDIT2)->EnableWindow();// 使能单选框
		}
	else
	{
		  GetDlgItem(IDC_STATIC3)->EnableWindow(FALSE);//变灰
		  GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);//变灰
		  m_key.Empty();					// 清空字符串
		  UpdateData(false);

	}
	
}

void CWLANConfiguratorDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	///点击"Connect"按钮设置

	  a.Empty();
	  b.Empty();
	  c.Empty();
	  d.Empty();
	  e.Empty();
	  f.Empty();
	  g.Empty();

	TCHAR appfilename[]=_T("\\Storage Card\\wzctool.exe");/////定义 wzctool.exe 路径

	if(OldOrNew == 1) ////////判断是点击"new setting" 还是点击"Default" 单选框
	{
		if(W8021x) /// 判断 8021x 是否为选中
		{
			if((int)SendDlgItemMessage(IDC_RADIO3, BM_GETCHECK, 0, 0))
			{
				a="8021x 0 " ;	// 判断 W8021x_none 是否为选中,选中则赋值给字符串变量a
			}
			if((int)SendDlgItemMessage(IDC_RADIO4, BM_GETCHECK, 0, 0))
			{
				a="8021x 1 " ;	// 判断 W8021x_TLS 是否为选中,选中则赋值给字符串变量a
			}
			if((int)SendDlgItemMessage(IDC_RADIO5, BM_GETCHECK, 0, 0))
			{
				a="8021x 2 " ;	// 判断 W8021x_md5 是否为选中,选中则赋值给字符串变量a
			}


		}
		if(adhoc) /// 判断 adhoc 是否为选中
		{
			if((int)SendDlgItemMessage(IDC_RADIO6, BM_GETCHECK, 0, 0))
			{
				b="ah 0 " ;	// 判断 adhoc中的"NO" 是否为选中,选中则赋值给字符串变量b
			}
			if((int)SendDlgItemMessage(IDC_RADIO7, BM_GETCHECK, 0, 0))
			{
				b="ah 1 " ;	// 判断 adhoc中的"Yes" 是否为选中,选中则赋值给字符串变量b
			}

		}

		if(authen)/// 判断 authen 是否为选中
		{
			if((int)SendDlgItemMessage(IDC_RADIO8, BM_GETCHECK, 0, 0))
			{
				c="am 0 " ;	// 判断 authen 中的"open" 是否为选中,选中则赋值给字符串变量c
			}
			if((int)SendDlgItemMessage(IDC_RADIO9, BM_GETCHECK, 0, 0))
			{
				c="am 1 " ;	// 判断 authen 中的"shared" 是否为选中,选中则赋值给字符串变量c
			}

		}

		if(wep)/// 判断 wep 是否为选中
		{
			// 判断 wep 中的"no" 是否为选中,选中则赋值给字符串变量d,e
			if((int)SendDlgItemMessage(IDC_RADIO10, BM_GETCHECK, 0, 0))
			{
				d="ws 0 " ;	
				e.Empty();
			    m_key.Empty();
			    UpdateData(false);
			}

			// 判断 wep 中的"yes" 是否为选中,选中则赋值给字符串变量d,e
			if((int)SendDlgItemMessage(IDC_RADIO11, BM_GETCHECK, 0, 0))
			{
				d="ws 1 wk " ;	
				e=m_key;
			
			}

		}
		f=m_SSID;    ///获取要连接的 SSID ,m_SSID 为IDC_EDIT1 字符串变量
		cmd = f + " " + a+b+c+d ; //wzctool.exe 需求最终网络参数
		g=_T("\\Storage Card\\Documents and Settings\\Wlan_set_" + f + ".txt") ;////存储网络参数配置文件路径及文件名Wlan_set_SSID.txt"
		////////以为为 wep key 从字符串转换为 16 进制 char 类型变量
		LPTSTR wepkey = e.GetBuffer(0);
		int i = 0;
		int nLen = e.GetLength(); /// 获取 wep key 长度
		char  OutBuf[512] ="" ;   /// 定义存放 wep key char 类型的 buffer
		/////把 wep key 转为 16 进制,存放到 buffer 中
		for( i = 1 ; i <=nLen ; i++) 
		{
			char  szTemp[512]="" ;
			sprintf(szTemp , "%x" , (unsigned char)wepkey[i-1]) ;
			strcat(OutBuf , szTemp ) ;
		}
		if(wepkey != NULL) *wepkey = _T('\0');
		e.ReleaseBuffer();
		//////////////////////////////////////////////////////////
	    ///////////////////把wep key 转换为 16 进制后再转换回CString 类,写入txt 中;
		e=(LPSTR)(LPCTSTR)OutBuf;
		/////////////////////////////////
		wzc_para = wzc_para + cmd + e;/////设置 wzctool.exe 最终参数
		DeleteFile(g); /////删除原来网络配置文件;
		Sleep(200);
		///////////////以下为把最终网络参数写入 txt 文件中。
		CFile mFile; 
		mFile.Open(g,CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite); 
		CArchive ar(&mFile, CArchive::store); 
		ar<<wzc_para;//////网络参数写入 txt 文件中
		ar.Close(); 
		mFile.Close(); 
        ////////////////////////////////////////////


	}


	////////////////////////////以下为按照"default"设定连接无线网络
	else
	{

		f=m_SSID;   ///获取 SSID
		g=_T("\\Storage Card\\Documents and Settings\\Wlan_set_" + f + ".txt") ; ///获取文件路径及名称
		//// 读取网络配置文件,把配置参数传送给wzc_para 变量
		CFile mFile; 
		if(mFile.Open(g,CFile::modeRead))
		{
			CArchive ar(&mFile, CArchive::load); 
			ar>>wzc_para; 
			ar.Close(); 
			mFile.Close(); 
		}

		else 
		{
			MessageBox(_T("Default WLAN configuration not exist!"),MB_OK);
			return;

		}
	}
	
    ////////////////////////////传递参数给 wzctool.exe 并启动 wzctool.exe 连接无线网络;
	CreateProcess(appfilename, (LPTSTR)(LPCTSTR)wzc_para, NULL, NULL, NULL, 0, NULL, NULL,NULL,NULL );
}

void CWLANConfiguratorDlg::OnChangeEdit1() 
{

	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
		UpdateData(true); 

}

void CWLANConfiguratorDlg::OnChangeEdit2() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData(true); 
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -