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

📄 mssqlbackupdlg.cpp

📁 MSSQL备份及恢复的VC++源代码。提供给大家学习。
💻 CPP
字号:
// MSSQLBackupDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MSSQLBackup.h"
#include "MSSQLBackupDlg.h"

#include "RcVersion.h"
#include <afxtempl.h>

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CStatic	m_StaticVersion;
	CListCtrl	m_ListReport;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

private:
	void InsertReportInfo();
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Control(pDX, IDC_STATIC_VERSION, m_StaticVersion);
	DDX_Control(pDX, IDC_LIST_REPORT, m_ListReport);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////////////////////////
// custom added

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	this->SetWindowText("关于 MSSQL Server冷备份");

	char szVersion[64]={0};
	strcpy(szVersion, "MSSQL Server冷备份 ");
	strcat(szVersion, MODEL_VERSION);
	strcat(szVersion, " 版");
	m_StaticVersion.SetWindowText(szVersion);
	
//	|LVS_EX_GRIDLINES(网格)
//	|LVS_SHOWSELALWAYS(高亮)
//	|LVS_EX_FLATSB(滑动条透明)
//	|LVS_EX_CHECKBOXES
	DWORD dwStyle;
	dwStyle=m_ListReport.GetExtendedStyle();
	m_ListReport.SetExtendedStyle(dwStyle|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_SHOWSELALWAYS);

//	CFont font;
//	font.CreateFont(15,0,0,0,FW_THIN,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,"宋体");
//	m_ListReport.SetFont(&font,TRUE);
	m_ListReport.InsertColumn(0,"版本号",LVCFMT_CENTER,59);
	m_ListReport.InsertColumn(1,"编写内容",LVCFMT_CENTER,260);

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

void CAboutDlg::InsertReportInfo()
{
	int iRet=0;
	iRet=m_ListReport.InsertItem(m_ListReport.GetItemCount(),"技术说明");
	m_ListReport.SetItemText(iRet,1,"使用SQL Distributed Management Objects object model接口");

	iRet=m_ListReport.InsertItem(m_ListReport.GetItemCount(),"V1.00.00");
	m_ListReport.SetItemText(iRet,1,"创建MSSQL Server冷备份");

	iRet=m_ListReport.InsertItem(m_ListReport.GetItemCount(),"V1.01.00");
	m_ListReport.SetItemText(iRet,1,"增加枚举局域网中所有MSSQL Server实例的功能");
}

/////////////////////////////////////////////////////////////////////////////
// CMSSQLBackupDlg dialog

CMSSQLBackupDlg::CMSSQLBackupDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMSSQLBackupDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMSSQLBackupDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_hInstance = NULL;
}

void CMSSQLBackupDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMSSQLBackupDlg)
	DDX_Control(pDX, IDC_COMBO_SERVERNAME, m_comboServerName);
	DDX_Control(pDX, IDC_EDIT_SERVERNAME, m_editServerName);
	DDX_Control(pDX, IDC_EDIT_USERNAME, m_editUserName);
	DDX_Control(pDX, IDC_EDIT_PASSWORD, m_editPassword);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMSSQLBackupDlg, CDialog)
	//{{AFX_MSG_MAP(CMSSQLBackupDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_ENUM, OnButtonEnum)
	ON_BN_CLICKED(IDC_BUTTON_ABOUT, OnButtonAbout)
	ON_BN_CLICKED(IDC_BUTTON_LOGIN, OnButtonLogin)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMSSQLBackupDlg message handlers

BOOL CMSSQLBackupDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	this->SetWindowText("MSSQL Server冷备份");

	m_editUserName.SetWindowText("sa");

	VERIFY(m_hInstance=::LoadLibrary("RcMSSQL.dll"));

	typedef BOOL (*DllInit)(HWND hWnd);
	DllInit pDllInit;
	VERIFY(pDllInit=(DllInit)::GetProcAddress(m_hInstance, "DllInitializtion"));
	if (!(pDllInit)(this->m_hWnd))
	{
//		MessageBox("rcmssql.dll加载失败!", "信息...", MB_OK);
		// Add code...
	}

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMSSQLBackupDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMSSQLBackupDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		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;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMSSQLBackupDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CMSSQLBackupDlg::PostNcDestroy() 
{
	CDialog::PostNcDestroy();
}

void CMSSQLBackupDlg::OnOK() 
{
	CDialog::OnOK();
}

void CMSSQLBackupDlg::OnCancel() 
{
	typedef BOOL (*DllComp)();
	DllComp pDllComp;
	VERIFY(pDllComp=(DllComp)::GetProcAddress(m_hInstance, "DllCompletion"));
	if (!(pDllComp)())
	{
//		MessageBox("rcmssql.dll加载失败!", "信息...", MB_OK);
		// Add code...
	}

	CDialog::OnCancel();
}

//////////////////////////////////////////////////////////////////////////////////////
// custom added

void CMSSQLBackupDlg::OnButtonAbout() 
{
	CAboutDlg dlg;
	dlg.DoModal();
}

void CMSSQLBackupDlg::OnButtonEnum() 
{
	CString strTemp;

	typedef LPCTSTR (*BrowseSvr)();
	BrowseSvr pBrowseSvr;
	VERIFY(pBrowseSvr=(BrowseSvr)::GetProcAddress(m_hInstance, "WBrowseServersDoModal"));
	strTemp=(pBrowseSvr)();

/*	typedef LPCTSTR (*GetSvrName)();
	GetSvrName pGetSvrName;
	VERIFY(pGetSvrName=(GetSvrName)::GetProcAddress(m_hInstance, "WGetServerName"));
	strTemp=(pGetSvrName)();*/
/*
	//GetInstalled is synonym for "pointer to function returning CArray<CString,CString&>*"
	typedef CArray<CString,CString&> * (*GetInstalled)();
	GetInstalled pGetInstalled;
	CArray<CString,CString&> * pArray;
	VERIFY(pGetInstalled=(GetInstalled)::GetProcAddress(hInstance, "EnumInstalledInstance"));
	pArray=(pGetInstalled)();
	for (int i=0; i < pArray->GetSize(); i++)
	{
		AfxMessageBox(pArray->ElementAt(i));
	}
*/
	m_editServerName.SetWindowText(strTemp);
	m_comboServerName.SetWindowText(strTemp);
}

void CMSSQLBackupDlg::OnButtonLogin() 
{
	
}

⌨️ 快捷键说明

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