ConfigNetwork.cpp
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:4k
- // ConfigNetwork.cpp : implementation file
- #include "stdafx.h"
- #include "trfAgent.h"
- #include "ConfigNetwork.h"
- // CConfigNetwork property page
- IMPLEMENT_DYNCREATE(CConfigNetwork, CPropertyPage)
- CConfigNetwork::CConfigNetwork() : CPropertyPage(CConfigNetwork::IDD)
- {
- //{{AFX_DATA_INIT(CConfigNetwork)
- m_bAutoRecvSvrsFles = FALSE;
- m_bAutoUpdate = FALSE;
- m_nDirSvrPort = 0;
- m_nRelayPort = 0;
- m_nTransPort = 0;
- //}}AFX_DATA_INIT
- }
- CConfigNetwork::~CConfigNetwork(){}
- void CConfigNetwork::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CConfigNetwork)
- DDX_Control(pDX, IDC_SVRIPADDR, m_oSvrIpAddr);
- DDX_Check(pDX, IDC_AUTORECVSVRSFLES, m_bAutoRecvSvrsFles);
- DDX_Check(pDX, IDC_AUTOUPDATE, m_bAutoUpdate);
- DDX_Text(pDX, IDC_PORT_DIRSVR, m_nDirSvrPort);
- DDX_Text(pDX, IDC_PORT_RELAY, m_nRelayPort);
- DDX_Text(pDX, IDC_PORT_TRANS, m_nTransPort);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CConfigNetwork, CPropertyPage)
- //{{AFX_MSG_MAP(CConfigNetwork)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- BOOL CConfigNetwork::Refresh()
- {
- //Load setting from registry
- CRegister regKey;
-
- if(!regKey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
- {
- TRACE0("Failed to open the registry keyn");
- return FALSE;
- }
-
- //@1---Network
- //Int
- DWORD dwValue = regKey.Read_DWord_Value(REG_STRFSERVER);
- if(0==dwValue)
- {
- this->m_oSvrIpAddr.SetAddress(127, 0, 0, 1);
- }
- else
- {
- this->m_oSvrIpAddr.SetAddress(dwValue);
- }
-
- dwValue = regKey.Read_DWord_Value(REG_NTRFTRANSPORT);
- this->m_nTransPort = (dwValue == 0 ? ENV_DEFAULT_TRFPORT : dwValue);
-
- dwValue = regKey.Read_DWord_Value(REG_NTRFRELAYPORT);
- this->m_nRelayPort = (dwValue == 0 ? ENV_DEFAULT_DELAYPORT : dwValue);
-
- dwValue = regKey.Read_DWord_Value(REG_NTRFDIRSVRPORT);
- this->m_nDirSvrPort= (dwValue == 0 ? ENV_DEFAULT_DIRSVRPORT : dwValue);
-
- //BOOL
- LONG l = regKey.Read_Bool_Value(REG_BAUTOUPDATE);
- this->m_bAutoUpdate = l;
-
- l = regKey.Read_Bool_Value(REG_BAUTORECVSVRSFLES);
- this->m_bAutoRecvSvrsFles = l;
- this->UpdateData(FALSE);
- return TRUE;
- }
- BOOL CConfigNetwork::OnSetActive()
- {
- return CPropertyPage::OnSetActive();
- }
- void CConfigNetwork::OnOK()
- {
- //Load setting from registry
- CRegister regKey;
-
- if(!regKey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
- {
- TRACE0("Failed to open the registry keyn");
- return ;
- }
-
- //@2---Network
- //Int
- DWORD dwValue = 0;
-
- this->m_oSvrIpAddr.GetAddress(dwValue);
- BOOL l = regKey.Write_DWord_Value(REG_STRFSERVER, dwValue);
- if(!l)
- {
- TRACE0("Failed to write string key valuen");
- return ;
- }
-
- dwValue = this->m_nTransPort;
- l = dwValue = regKey.Write_DWord_Value(REG_NTRFTRANSPORT, dwValue);
- if(!l)
- {
- TRACE0("Failed to write string key valuen");
- return ;
- }
-
- dwValue = this->m_nRelayPort;
- l = regKey.Write_DWord_Value(REG_NTRFRELAYPORT, dwValue);
- if(!l)
- {
- TRACE0("Failed to write string key valuen");
- return ;
- }
-
- dwValue = this->m_nDirSvrPort;
- l = regKey.Write_DWord_Value(REG_NTRFDIRSVRPORT, dwValue);
- if(!l)
- {
- TRACE0("Failed to write string key valuen");
- return ;
- }
-
- //BOOL
- l = regKey.Write_Bool_Value(REG_BAUTOUPDATE, this->m_bAutoUpdate);
- if(!l)
- {
- TRACE0("Failed to write string key valuen");
- return ;
- }
-
- l = regKey.Write_Bool_Value(REG_BAUTORECVSVRSFLES, this->m_bAutoRecvSvrsFles);
- if(!l)
- {
- TRACE0("Failed to write string key valuen");
- return ;
- }
- CPropertyPage::OnOK();
- }
- BOOL CConfigNetwork::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
-
- if(!this->Refresh())
- {
- return FALSE;
- }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }