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

📄 dlgsetftp.cpp

📁 电子监控的网络编程实例
💻 CPP
字号:
// DlgSetFTP.cpp : implementation file
//

#include "stdafx.h"
#include "videocapture.h"
#include "DlgSetFTP.h"
#include "VideoCaptureView.h"

typedef PCHAR (__stdcall * pPassWordCode)(PCHAR ByString,boolean DeCode= true);

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgSetFTP dialog


CDlgSetFTP::CDlgSetFTP(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgSetFTP::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgSetFTP)
	m_ftp = _T("");
	m_user = _T("");
	m_password = _T("");
	//}}AFX_DATA_INIT
}


void CDlgSetFTP::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgSetFTP)
	DDX_Text(pDX, IDC_EDIT1, m_ftp);
	DDV_MaxChars(pDX, m_ftp, 256);
	DDX_Text(pDX, IDC_EDIT2, m_user);
	DDV_MaxChars(pDX, m_user, 256);
	DDX_Text(pDX, IDC_EDIT3, m_password);
	DDV_MaxChars(pDX, m_password, 256);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgSetFTP, CDialog)
	//{{AFX_MSG_MAP(CDlgSetFTP)
	ON_WM_SHOWWINDOW()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgSetFTP message handlers

BOOL CDlgSetFTP::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CVideoCaptureView* pView=CVideoCaptureView::GetView();
	if(pView)
	{
			m_ftp=pView->ftp.Server;
			m_user=pView->ftp.UserID;
			m_password=pView->ftp.Password;
			UpdateData(FALSE);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgSetFTP::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	CVideoCaptureView* pView=CVideoCaptureView::GetView();
	if(pView)
		pView->IsCapturing=TRUE;
	
}

void CDlgSetFTP::OnOK() 
{
	CVideoCaptureView* pView=CVideoCaptureView::GetView();
	while(!pView)
		pView=CVideoCaptureView::GetView();	
	UpdateData();

	if(pView->TransMode==2/*ftp IP*/)
	{
		if (pView->UpdateIP(m_ftp,m_user,m_password,".\\"+pView->m_szMachineID+pView->m_szAddress+".ini")==0)
		{
			pView->ftp.Password=m_password;
			pView->ftp.UserID=m_user;
			pView->ftp.Server=m_ftp;
			::WritePrivateProfileString("NET","FTP",m_ftp,".\\config.ini");
			::WritePrivateProfileString("NET","USERID",m_user,".\\config.ini");
			
			//调用打印模版  打印报表
			HINSTANCE hLibrary;
			pPassWordCode PassWordCode;		
			hLibrary=LoadLibrary(".\\crypt.dll");
			if(!hLibrary)
			{
				ShowMessage("加密模块crypt.dll丢失");
				return ;
			}
			PassWordCode=(pPassWordCode)GetProcAddress(hLibrary,"PassWordCode");
			LPCSTR aa3;
			aa3= (*PassWordCode)(m_password.GetBuffer(0),true);
			//ftp.Password=aa3;
			CString strstr=aa3;
			FreeLibrary(hLibrary);
			
			::WritePrivateProfileString("NET","PASSWORD",strstr,".\\config.ini");
			CDialog::OnOK();
		}
	}
	else if (pView->TransMode==3/*FTP*/)
	{
		if (pView->ConnectFTP(m_ftp,m_user,m_password))
		{
			pView->ftp.Password=m_password;
			pView->ftp.UserID=m_user;
			pView->ftp.Server=m_ftp;
			::WritePrivateProfileString("NET","FTP",m_ftp,".\\config.ini");
			::WritePrivateProfileString("NET","USERID",m_user,".\\config.ini");
			
			//调用打印模版  打印报表
			HINSTANCE hLibrary;
			pPassWordCode PassWordCode;		
			hLibrary=LoadLibrary(".\\crypt.dll");
			if(!hLibrary)
			{
				ShowMessage("加密模块crypt.dll丢失");
				return ;
			}
			PassWordCode=(pPassWordCode)GetProcAddress(hLibrary,"PassWordCode");
			LPCSTR aa3;
			aa3= (*PassWordCode)(m_password.GetBuffer(0),true);
			//ftp.Password=aa3;
			CString strstr=aa3;
			FreeLibrary(hLibrary);
			
			::WritePrivateProfileString("NET","PASSWORD",strstr,".\\config.ini");
			
			CDialog::OnOK();
		}		
	}
	else 
	{
		CDialog::OnOK();
	}
	
}

⌨️ 快捷键说明

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