using CnasSynchronousCommon; using CnasSynchronusClient; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace CNAS_DBSync { public partial class frmOperationPwd : Form { public frmOperationPwd() { InitializeComponent(); } private void btnOK_Click(object sender, EventArgs e) { Config(); } public void Config() { //获取本地存储的操作密码 string strPwd = FileOperation.GetLocalOperationPwd(); if (this.txtOldPwd.Text.Trim() == strPwd) { this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("密码无效."); } } private void frmOperationPwd_KeyDown(object sender, KeyEventArgs e) { try { if (!btnOK.Focused) { FormKeyEventClass fke = new FormKeyEventClass(); fke.FormKeyEvent += new FormKeyEventClass.FormKey(Config); fke.FormKeyEventRun(e); } } catch (Exception ex) { AppLog.Error(ex.Message.ToString()); } } [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern bool ReleaseCapture(); [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); public const int WM_SYSCOMMAND = 0x0112; public const int SC_MOVE = 0xF010; public const int HTCAPTION = 0x0002; private void frmOperationPwd_MouseDown(object sender, MouseEventArgs e) { try { ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); } catch (Exception ex) { AppLog.Error(ex.Message.ToString()); } } } }