初始化上传

This commit is contained in:
2025-08-26 08:37:44 +08:00
commit 31d81b91b6
448 changed files with 80981 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
using Avalonia;
using Avalonia.Markup.Xaml.MarkupExtensions;
using Avalonia.Platform;
using MES.Utility.Core;
using Microsoft.Win32;
using System;
using System.IO;
using Ursa.Controls;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class AdobeAcrobatXI破解ViewModel : ViewModelBase
{
public string FilePath { get; set; } = "";
public DelegateCommand FindPathCmd { get; set; }
public DelegateCommand CrackCmd { get; set; }
public AdobeAcrobatXI破解ViewModel()
{
FindPathCmd = new DelegateCommand(FindPathCmdFunc);
CrackCmd = new DelegateCommand(CrackCmdFunc);
}
private void FindPathCmdFunc(object obj)
{
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software");
registryKey = registryKey.OpenSubKey("Adobe");
if (registryKey == null)
{
MessageBox.ShowAsync("当前计算机未安装Adobe Acrobat XI");
return;
}
registryKey = registryKey.OpenSubKey("Adobe Acrobat");
if (registryKey == null)
{
MessageBox.ShowAsync("当前计算机未安装Adobe Acrobat XI");
return;
}
registryKey = registryKey.OpenSubKey("11.0");
if (registryKey == null)
{
MessageBox.ShowAsync("当前计算机未安装Adobe Acrobat XI");
return;
}
registryKey = registryKey.OpenSubKey("InstallPath");
if (registryKey == null)
{
MessageBox.ShowAsync("获得路径失败,请手动输入路径");
return;
}
string path = registryKey.GetValue("").ToString();
FilePath = path;
}
private void CrackCmdFunc(object obj)
{
try
{
string path = FilePath;
if (path.IsNullOrEmpty())
{
MessageBox.ShowAsync("请查找或者输入Adobe Acrobat XI安装目录");
return;
}
if (!Directory.Exists(path))
{
MessageBox.ShowAsync("文件夹不存在,破解失败");
return;
}
path = path.Replace("\\", "/");
if (!path.EndsWith("/"))
path += "/";
path += "amtlib.dll";
byte[] bytes = null;
// 获取Pack URI
string packUri = "avares://常用工具集/Assets/AcrobatXI/amtlib.dll";
// 使用Pack URI打开文件并读取内容
if (!File.Exists(path))
{
MessageBox.ShowAsync("amtlib.dll文件不存在请手动输入路径");
return;
}
using (Stream stream = AssetLoader.Open(new Uri(packUri)))
{
bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
}
using (FileStream fs = new FileStream(path, FileMode.Create))
{
using (BinaryWriter bw = new BinaryWriter(fs))
{
bw.Write(bytes);
}
}
MessageBox.ShowAsync("破解完成");
}
catch (Exception ex)
{
MessageBox.ShowAsync("破解失败:" + ex.Message);
}
}
}
}

View File

@@ -0,0 +1,92 @@
using Microsoft.Win32.TaskScheduler;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Ursa.Controls;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class MySQL定时备份ViewModel : ViewModelBase
{
public string FilePath { get; set; } = "";
public string UserName { get; set; } = "root";
public string Password { get; set; } = "root";
public string DatabaseName { get; set; } = "test";
public TimeSpan SelectedTime { get; set; } = TimeSpan.Zero;
public string BackPath { get; set; } = "d:/test.sql";
public DelegateCommand FindPathCmd { get; set; }
public DelegateCommand CreateBackPlanCmd { get; set; }
public MySQL定时备份ViewModel()
{
FindPathCmd = new DelegateCommand(FindPathCmdFunc);
CreateBackPlanCmd = new DelegateCommand(CreateBackPlanCmdFunc);
}
private void FindPathCmdFunc(object obj)
{
try
{
Process process = Process.GetProcesses().Where(it => it.ProcessName.ToLower().Contains("mysql")).FirstOrDefault();
if (process == null)
{
MessageBox.ShowAsync("找不到MySQL安装路径");
return;
}
string path = process.MainModule.FileName;
path = Directory.GetParent(path).FullName;
FilePath = path;
}
catch
{
MessageBox.ShowAsync("找不到MySQL安装路径");
}
}
private void CreateBackPlanCmdFunc(object obj)
{
string binPath = FilePath.Replace("\\", "/");
if (string.IsNullOrEmpty(binPath))
{
MessageBox.ShowAsync("请输入mysqldump所在目录");
return;
}
if (!binPath.EndsWith("/"))
{
binPath = binPath + "/";
}
if (!Directory.Exists(binPath))
{
MessageBox.ShowAsync("mysqldump所在目录不存在");
return;
}
string userName = UserName;
string password = Password;
string dbName = DatabaseName;
string backupFile = BackPath;
string cmd = $"mysqldump -u {userName} -p{password} {dbName} > {backupFile}";
string batPath = $"{dbName}_back.bat";
File.WriteAllText(binPath + batPath, cmd);
using (TaskService ts = new TaskService())
{
// 创建新的任务定义并指定任务的名称
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "MySQL定时备份";
// 创建触发器,设置为每天的特定时间
DailyTrigger dailyTrigger = new DailyTrigger();
dailyTrigger.StartBoundary = DateTime.Today.Add(SelectedTime); //指定时间
td.Triggers.Add(dailyTrigger);
// 创建操作 - 运行一个程序
td.Actions.Add(new ExecAction(batPath, "", binPath));
// 注册任务到根文件夹下
ts.RootFolder.RegisterTaskDefinition("MySQLBackup", td);
}
GlobalValues.Success("已创建备份计划");
}
}
}

View File

@@ -0,0 +1,176 @@
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Runtime.InteropServices;
using Ursa.Controls;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class ViewModel : ViewModelBase
{
private SerialHelper helper;
public bool Enabled { get; set; } = true;
public string ButtonText { get; set; } = "打开";
public DelegateCommand ButtonCmd { get; set; }
//串口号下拉列表数据
public List<string> SerialList { get; set; }
public int SerialIndex { get; set; } = 0;
/// <summary>
/// 波特率
/// </summary>
public List<int> BaudRateList { get; set; }
public int BaudRateIndex { get; set; } = 0;
//校验
public List<string> ParityList { get; set; }
public int ParityIndex { get; set; } = 0;
//数据为
public List<int> DataBitList { get; set; }
public int DataBitIndex { get; set; } = 0;
//停止位
public List<string> StopBitList { get; set; }
public int StopBitIndex { get; set; } = 0;
public int Timeout { get; set; } = 1000;
public ViewModel()
{
//串口号
string[] portNames = SerialPort.GetPortNames();
if (portNames != null && portNames.Length > 0)
{
SerialList = portNames.ToList();
}
//波特率
BaudRateList = new List<int>() { 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 56000, 57600, 115200, 128000 };
BaudRateIndex = 6;
//校验
ParityList = new List<string> { "None", "Odd", "Even", "Mark", "Space" };
ParityIndex = 0;
//数据位
DataBitList = new List<int> { 5, 6, 7, 8 };
DataBitIndex = 3;
//停止位
StopBitList = new List<string> { "None", "One", "Two", "OnePointFive" };
StopBitIndex = 1;
ButtonCmd = new DelegateCommand(ButtonCmdFunc);
}
private void ButtonCmdFunc(object obj)
{
if (ButtonText == "打开")
{
try
{
helper = new SerialHelper(
SerialList[SerialIndex],
BaudRateList[BaudRateIndex],
DataBitList[DataBitIndex],
(StopBits)StopBitIndex,
(Parity)ParityIndex,
Timeout
);
helper.Open();
}
catch
{
MessageBox.ShowAsync("串口打开失败");
return;
}
Enabled = false;
ButtonText = "关闭";
GlobalValues.MainWindow.WindowState = Avalonia.Controls.WindowState.Minimized;
}
else
{
helper.Close();
helper = null;
Enabled = true;
ButtonText = "打开";
}
}
public class SerialHelper
{
[DllImport("user32")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
const uint KEYEVENTF_EXTENDEDKEY = 0x1;
const uint KEYEVENTF_KEYUP = 0x2;
private SerialPort serialPort;
public SerialHelper(string portName, int baudRate, int dataBits, StopBits stopBits, Parity parity, int timeout)
{
serialPort = new SerialPort();
serialPort.PortName = portName;
serialPort.BaudRate = baudRate;
serialPort.DataBits = dataBits;
serialPort.StopBits = stopBits;
serialPort.Parity = parity;
serialPort.ReadTimeout = timeout;
serialPort.DataReceived += SerialPort1_DataReceived;
}
/// <summary>
/// 打开串口
/// </summary>
public void Open()
{
if (serialPort.IsOpen)
return;
serialPort.Open();
}
/// <summary>
/// 关闭串口
/// </summary>
public void Close()
{
if (!serialPort.IsOpen)
return;
serialPort.Close();
}
private void SerialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
int n = serialPort.BytesToRead;
byte[] buf = new byte[n];
serialPort.Read(buf, 0, n);
foreach (byte b in buf)
{
if (b >= '0' && b <= '9')
{
keybd_event(b, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(b, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
else if (b >= 'a' && b <= 'z')
{
keybd_event((byte)(b - 32), 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event((byte)(b - 32), 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
else if (b >= 'A' && b <= 'Z')
{
keybd_event(16, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);//按下Shift键
keybd_event(b, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(b, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
keybd_event(16, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);//松开Shift键
}
else if (b == 0x0D || b == 0x0A)
{
keybd_event(0x0D, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(0x0D, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
}
}
}
}
}

View File

@@ -0,0 +1,78 @@
using Base.Utility;
using Microsoft.Win32;
using System.Collections.Generic;
using System.Linq;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class WPS图标ViewModel : ViewModelBase
{
private string name1 = "{7AE6DE87-C956-4B40-9C89-3D166C9841D3}";
private string name2 = "{5FCD4425-CA3A-48F4-A57C-B8A75C32ACB1}";
private string name3 = "{19ADA707-057F-45EF-8985-305FEE233FAB}";
public DelegateCommand ClearCmd { get; set; }
public WPS图标ViewModel()
{
ClearCmd = new DelegateCommand(ClearCmdFunc);
}
private void ClearCmdFunc(object obj)
{
Delete(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\", name2);
Delete(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\", name1);
Delete(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\", name2);
Delete(@"SOFTWARE\Classes\CLSID", name1);
Delete(@"SOFTWARE\Classes\CLSID", name2);
Delete(@"SOFTWARE\Classes\SOFTWARE\Classes\CLSID", name1);
Delete(@"SOFTWARE\Classes\SOFTWARE\Classes\CLSID", name2);
Delete(@"SOFTWARE\Classes\SOFTWARE\Classes\Wow6432Node\CLSID", name3);
Delete(@"SOFTWARE\Classes\SOFTWARE\Classes\Wow6432Node\CLSID", name2);
Delete(@"SOFTWARE\Classes\SOFTWARE\Classes\Wow6432Node\CLSID", name1);
Delete(@"SOFTWARE\Classes\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace", name1);
Delete(@"SOFTWARE\Classes\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace", name2);
Delete(@"SOFTWARE\Classes\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace", name1);
Delete(@"SOFTWARE\Classes\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace", name2);
DeleteKey(@"SOFTWARE\Classes\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", name1);
DeleteKey(@"SOFTWARE\Classes\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", name2);
DeleteKey(@"SOFTWARE\Classes\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", name1);
DeleteKey(@"SOFTWARE\Classes\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", name2);
DeleteKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", name1);
DeleteKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", name2);
DeleteKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", name1);
DeleteKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved", name2);
Delete(@"SOFTWARE\Classes\WOW6432Node\CLSID", name3);
Delete(@"SOFTWARE\Classes\WOW6432Node\CLSID", name2);
Delete(@"SOFTWARE\Classes\WOW6432Node\CLSID", name1);
Delete(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace", name1);
//重新打开桌面
DesktopRefurbish.DeskRef();
}
private void DeleteKey(string path, string name1)
{
try
{
RegistryKey user = Registry.CurrentUser;
RegistryKey key = user.OpenSubKey(path, true);
key.DeleteValue(name1);
}
catch { }
}
private void Delete(string path, string name1)
{
try
{
RegistryKey user = Registry.CurrentUser;
RegistryKey key = user.OpenSubKey(path, true);
List<string> names = key.GetSubKeyNames().ToList();
if (names.Contains(name1))
{
key.DeleteSubKey(name1);
}
}
catch { }
}
}
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class ViewModel : ViewModelBase
{
public DelegateCommand ClearCmd { get; set; }
public ViewModel()
{
ClearCmd = new DelegateCommand(ClearCmdFunc);
}
public void ClearCmdFunc(object obj)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("rem 关闭Windows外壳程序explorer");
sb.AppendLine("taskkill /f /im explorer.exe");
sb.AppendLine("rem 清理系统图标缓存数据库");
sb.AppendLine("attrib -h -s -r \"%userprofile%\\AppData\\Local\\IconCache.db\"");
sb.AppendLine("del /f \"%userprofile%\\AppData\\Local\\IconCache.db\"");
sb.AppendLine("attrib /s /d -h -s -r \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\*\"");
sb.AppendLine("del /f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_32.db\"");
sb.AppendLine("del /f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_96.db\"");
sb.AppendLine("del /f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_102.db\"");
sb.AppendLine("del /f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_256.db\"");
sb.AppendLine("del /f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_1024.db\"");
sb.AppendLine("del /f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_idx.db\"");
sb.AppendLine("del /f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_sr.db\"");
sb.AppendLine("rem 清理 系统托盘记忆的图标");
sb.AppendLine("echo y|reg delete \"HKEY_CLASSES_ROOT\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\TrayNotify\" /v IconStreams");
sb.AppendLine("echo y|reg delete \"HKEY_CLASSES_ROOT\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\TrayNotify\" /v PastIconsStream");
sb.AppendLine("rem 重启Windows外壳程序explorer");
sb.AppendLine("start explorer");
string tempPath = Path.GetTempFileName();
tempPath += ".bat";
try
{
File.WriteAllText(tempPath, sb.ToString(), Encoding.GetEncoding("GB2312"));
}
catch
{
File.WriteAllText(tempPath, sb.ToString(), Encoding.UTF8);
}
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = tempPath,
UseShellExecute = true, //不使用操作系统外壳程序启动
CreateNoWindow = true
};
using (Process process = Process.Start(startInfo))
{
process.WaitForExit(); // 等待批处理执行完成
File.Delete(tempPath);
}
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class ViewModel : ViewModelBase
{
public DelegateCommand ButtonCmd { get; set; }
public ViewModel()
{
ButtonCmd = new DelegateCommand(ButtonCmdFunc);
}
private void ButtonCmdFunc(object obj)
{
var p = new Process();
p.StartInfo = new ProcessStartInfo(@"ncpa.cpl")
{
UseShellExecute = true
};
p.Start();
}
}
}

View File

@@ -0,0 +1,133 @@
using CZGL.SystemInfo;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class ViewModel : ViewModelBase
{
public string OSArchitecture { get; set; } = "";
public string OSPlatformID { get; set; } = "";
public string OSVersion { get; set; } = "";
public string OSDescription { get; set; } = "";
public string ProcessArchitecture { get; set; } = "";
public string ProcessorCount { get; set; } = "";
public string MachineName { get; set; } = "";
public string FrameworkVersion { get; set; } = "";
public string FrameworkDescription { get; set; } = "";
public string CPURate { get; set; } = "";
public string MemoryRate { get; set; } = "";
public string UploadSpeed { get; set; } = "";
public string DownloadSpeed { get; set; } = "";
public ObservableCollection<MyDisk> DataList { get; set; }
public ViewModel()
{
DataList = new ObservableCollection<MyDisk>();
DiskInfo[] diskInfo = DiskInfo.GetDisks();
foreach (DiskInfo info in diskInfo)
{
MyDisk myDisk = new MyDisk();
myDisk.Name = info.Name;
myDisk.SetValue(info.TotalSize, info.UsedSize, info.FreeSpace);
DataList.Add(myDisk);
}
OSArchitecture = SystemPlatformInfo.OSArchitecture;
OSPlatformID = SystemPlatformInfo.OSPlatformID;
OSVersion = SystemPlatformInfo.OSVersion;
OSDescription = SystemPlatformInfo.OSDescription;
ProcessArchitecture = SystemPlatformInfo.ProcessArchitecture;
ProcessorCount = SystemPlatformInfo.ProcessorCount.ToString();
MachineName = SystemPlatformInfo.MachineName;
FrameworkVersion = SystemPlatformInfo.FrameworkVersion;
FrameworkDescription = SystemPlatformInfo.FrameworkDescription;
new Thread(() =>
{
CPUTime v1 = CPUHelper.GetCPUTime();
var network = NetworkInfo.TryGetRealNetworkInfo();
var oldRate = network.GetIpv4Speed();
while (true)
{
try
{
Thread.Sleep(1000);
var v2 = CPUHelper.GetCPUTime();
var value = CPUHelper.CalculateCPULoad(v1, v2);
v1 = v2;
var memory = MemoryHelper.GetMemoryValue();
var newRate = network.GetIpv4Speed();
var speed = NetworkInfo.GetSpeed(oldRate, newRate);
oldRate = newRate;
CPURate = $"{(int)(value * 100)} %";
MemoryRate = $"{memory.UsedPercentage}%";
UploadSpeed = $"{speed.Sent.Size} {speed.Sent.SizeType}/S";
DownloadSpeed = $"{speed.Received.Size} {speed.Received.SizeType}/S";
DiskInfo[] diskInfos = DiskInfo.GetDisks();
foreach (DiskInfo info1 in diskInfos)
{
MyDisk disk = DataList.Where(it => it.Name == info1.Name).FirstOrDefault();
if (disk != null)
{
disk.SetValue(info1.TotalSize, info1.UsedSize, info1.FreeSpace);
}
}
}
catch
{
Thread.Sleep(10);
}
}
}).Start();
}
}
public class MyDisk : ViewModelBase
{
public void SetValue(long total, long used, long free)
{
Total = GetLength(total);
Used = GetLength(used);
Free = GetLength(free);
}
public string Name { get; set; }
public string Total { get; set; }
public string Used { get; set; }
public string Free { get; set; }
private string GetLength(long bytes)
{
double tb = Math.Pow(1024.0, 4);
if (bytes > tb)
{
return $"{((int)((bytes / tb) * 100)) / 100.0f}TB";
}
double gb = Math.Pow(1024.0, 3);
if (bytes > gb)
{
return $"{((int)((bytes / gb) * 100)) / 100.0f}GB";
}
double mb = Math.Pow(1024.0, 2);
if (bytes > mb)
{
return $"{((int)((bytes / mb) * 100)) / 100.0f}MB";
}
else if (bytes > 1024)
{
return $"{((int)((bytes / 1024.0f) * 100)) / 100.0f}KB";
}
else
{
return $"{bytes}Byte";
}
}
}
}

View File

@@ -0,0 +1,105 @@
using Avalonia.Platform;
using Base.Utility;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class ViewModel : ViewModelBase
{
public DelegateCommand Button1Cmd { get; set; }
public DelegateCommand Button2Cmd { get; set; }
public ViewModel()
{
Button1Cmd = new DelegateCommand(Button1CmdFunc);
Button2Cmd = new DelegateCommand(Button2CmdFunc);
}
/// <summary>
/// 编程猫猫回收站
/// </summary>
/// <param name="obj"></param>
private void Button1CmdFunc(object obj)
{
RegistryKey user = Registry.CurrentUser;
RegistryKey CLSID = user.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\");
RegistryKey icon = CLSID.OpenSubKey("{645FF040-5081-101B-9F08-00AA002F954E}", true);
RegistryKey defaultIcon = icon.CreateSubKey("DefaultIcon");
//把dll复制到c:/System目录下
byte[] fullDllBytes = null;
// 获取Pack URI
string packUri = "avares://常用工具集/Assets/Cat/full.dll";
// 使用Pack URI打开文件并读取内容
using (Stream stream = AssetLoader.Open(new Uri(packUri)))
{
fullDllBytes = new byte[stream.Length];
stream.Read(fullDllBytes, 0, fullDllBytes.Length);
}
byte[] emptyDllBytes = null;
// 获取Pack URI
string packUri2 = "avares://常用工具集/Assets/Cat/empty.dll";
// 使用Pack URI打开文件并读取内容
using (Stream stream = AssetLoader.Open(new Uri(packUri2)))
{
emptyDllBytes = new byte[stream.Length];
stream.Read(emptyDllBytes, 0, emptyDllBytes.Length);
}
string path = Environment.GetEnvironmentVariable("USERPROFILE");
string appData = path + "\\AppData";
DirectoryInfo directoryInfo = new DirectoryInfo(appData);
if (!directoryInfo.Exists)
directoryInfo.Create();
string myDir = appData + "\\catIco";
DirectoryInfo directoryInfo2 = new DirectoryInfo(myDir);
if (!directoryInfo2.Exists)
directoryInfo2.Create();
string fullDllPath = myDir + "\\full.dll";
string emptyDllPath = myDir + "\\empty.dll";
if (File.Exists(fullDllPath))
File.Delete(fullDllPath);
if (File.Exists(emptyDllPath))
File.Delete(emptyDllPath);
using (FileStream stream = new FileStream(fullDllPath, FileMode.Create))
stream.Write(fullDllBytes, 0, fullDllBytes.Length);
using (FileStream stream = new FileStream(emptyDllPath, FileMode.Create))
stream.Write(emptyDllBytes, 0, emptyDllBytes.Length);
defaultIcon.SetValue("", @"%USERPROFILE%\AppData\catIco\empty.dll,0", RegistryValueKind.ExpandString);
defaultIcon.SetValue("Full", @"%USERPROFILE%\AppData\catIco\full.dll,0", RegistryValueKind.ExpandString);
defaultIcon.SetValue("Empty", @"%USERPROFILE%\AppData\catIco\empty.dll,0", RegistryValueKind.ExpandString);
//重新打开桌面
DesktopRefurbish.DeskRef();
}
/// <summary>
/// 还原
/// </summary>
/// <param name="obj"></param>
private void Button2CmdFunc(object obj)
{
RegistryKey user = Registry.CurrentUser;
RegistryKey CLSID = user.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\");
RegistryKey icon = CLSID.OpenSubKey("{645FF040-5081-101B-9F08-00AA002F954E}", true);
RegistryKey defaultIcon = icon.CreateSubKey("DefaultIcon");
defaultIcon.SetValue("", @"%SystemRoot%\System32\imageres.dll,-55", RegistryValueKind.ExpandString);
defaultIcon.SetValue("Full", @"%SystemRoot%\System32\imageres.dll,-54", RegistryValueKind.ExpandString);
defaultIcon.SetValue("Empty", @"%SystemRoot%\System32\imageres.dll,-55", RegistryValueKind.ExpandString);
//重新打开桌面
DesktopRefurbish.DeskRef();
}
}
}

View File

@@ -0,0 +1,83 @@
using System;
using System.Diagnostics;
using System.IO;
using Ursa.Controls;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class ViewModel : ViewModelBase
{
public string RemotePath { get; set; } = "\\\\10.150.0.250\\运维软件";
public string LocalPath { get; set; } = "d:\\运维软件";
public DelegateCommand MakeLinkCmd { get; set; }
public ViewModel()
{
MakeLinkCmd = new DelegateCommand(MakeLinkCmdFunc);
}
private void MakeLinkCmdFunc(object obj)
{
if (string.IsNullOrEmpty(LocalPath) || string.IsNullOrEmpty(RemotePath))
{
MessageBox.ShowAsync("请输入路径");
return;
}
string remotePath = RemotePath;
string localPath = LocalPath.Replace("/", "\\");
bool flag = CreateSymbolicLink(remotePath, localPath);
if (flag)
{
GlobalValues.Success("创建成功");
}
else
{
GlobalValues.Error("创建失败");
}
}
private bool CreateSymbolicLink(string remotePath, string localPath)
{
try
{
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true
};
process.StartInfo = startInfo;
process.Start();
process.StandardInput.WriteLine($"mklink /d {localPath} {remotePath}");
process.StandardInput.AutoFlush = true;
process.StandardInput.WriteLine("exit");
StreamReader reader = process.StandardOutput;
string ret = "";
while (true)
{
string curLine = reader.ReadLine();
ret = ret + curLine + "\r\n";
Console.WriteLine(curLine);
if (reader.EndOfStream)
{
break;
}
}
reader.Close();
process.Close();
if (ret.Contains("<<===>>"))
return true;
return false;
}
catch
{
return false;
}
}
}
}

View File

@@ -0,0 +1,893 @@
using Avalonia.Controls;
using MES.Utility.EventBus;
using System;
using System.Runtime.InteropServices;
using System.Windows;
using Weiz.EventBus.Core;
using .Base;
namespace .ViewModel._04破解及系统相关
{
public class ViewModel : ViewModelBase, IEventHandler<KeyBordHookEvent>
{
public string ButtonText { get; set; } = "开启键盘钩子";
public string Message { get; set; } = "";
public DelegateCommand StartStopCmd { get; set; }
public DelegateCommand CleanCmd { get; set; }
public DelegateCommand PageLoaedCommand { get; set; }
public ViewModel()
{
EventBus.Instance.Subscribe<KeyBordHookEvent>(this);
PageLoaedCommand = new DelegateCommand(PageLoaded);
StartStopCmd = new DelegateCommand(StartStopCmdFunc);
CleanCmd = new DelegateCommand(CleanCmdFunc);
}
private void PageLoaded(object obj)
{
}
private void StartStopCmdFunc(object obj)
{
if (ButtonText == "开启键盘钩子")
{
KeyboardHook.Start();
ButtonText = "停止键盘钩子";
GlobalValues.MainWindow.WindowState = WindowState.Minimized;
}
else
{
KeyboardHook.Stop();
ButtonText = "开启键盘钩子";
}
}
private void CleanCmdFunc(object obj)
{
Message = "";
}
public void Handle(KeyBordHookEvent evt)
{
Message += evt.Message;
}
}
public class KeyboardHook
{
private const int WH_KEYBOARD_LL = 13;
private static LowLevelKeyboardProc _proc = HookCallback;
private static IntPtr _hookID = IntPtr.Zero;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool UnhookWindowsHookEx(IntPtr hhk);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr GetModuleHandle(string lpModuleName);
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
public static void Start()
{
_hookID = SetWindowsHookEx(WH_KEYBOARD_LL, _proc, GetModuleHandle(null), 0);
if (_hookID == IntPtr.Zero)
{
throw new Exception("Could not set keyboard hook");
}
}
public static void Stop()
{
bool ret = UnhookWindowsHookEx(_hookID);
if (!ret)
{
throw new Exception("Could not unset keyboard hook");
}
_hookID = IntPtr.Zero;
}
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode >= 0 && wParam == (IntPtr)0x100)
{
int vkCode = Marshal.ReadInt32(lParam);
Console.WriteLine((Keys)vkCode);
EventBus.Instance.Publish(new KeyBordHookEvent(((Keys)vkCode).ToString()));
}
return CallNextHookEx(_hookID, nCode, wParam, lParam);
}
}
public enum Keys
{
//
// 摘要:
// The bitmask to extract modifiers from a key value.
Modifiers = -65536,
//
// 摘要:
// No key pressed.
None = 0,
//
// 摘要:
// The left mouse button.
LButton = 1,
//
// 摘要:
// The right mouse button.
RButton = 2,
//
// 摘要:
// The CANCEL key.
Cancel = 3,
//
// 摘要:
// The middle mouse button (three-button mouse).
MButton = 4,
//
// 摘要:
// The first x mouse button (five-button mouse).
XButton1 = 5,
//
// 摘要:
// The second x mouse button (five-button mouse).
XButton2 = 6,
//
// 摘要:
// The BACKSPACE key.
Back = 8,
//
// 摘要:
// The TAB key.
Tab = 9,
//
// 摘要:
// The LINEFEED key.
LineFeed = 10,
//
// 摘要:
// The CLEAR key.
Clear = 12,
//
// 摘要:
// The RETURN key.
Return = 13,
//
// 摘要:
// The ENTER key.
Enter = 13,
//
// 摘要:
// The SHIFT key.
ShiftKey = 16,
//
// 摘要:
// The CTRL key.
ControlKey = 17,
//
// 摘要:
// The ALT key.
Menu = 18,
//
// 摘要:
// The PAUSE key.
Pause = 19,
//
// 摘要:
// The CAPS LOCK key.
Capital = 20,
//
// 摘要:
// The CAPS LOCK key.
CapsLock = 20,
//
// 摘要:
// The IME Kana mode key.
KanaMode = 21,
//
// 摘要:
// The IME Hanguel mode key. (maintained for compatibility; use HangulMode)
HanguelMode = 21,
//
// 摘要:
// The IME Hangul mode key.
HangulMode = 21,
//
// 摘要:
// The IME Junja mode key.
JunjaMode = 23,
//
// 摘要:
// The IME final mode key.
FinalMode = 24,
//
// 摘要:
// The IME Hanja mode key.
HanjaMode = 25,
//
// 摘要:
// The IME Kanji mode key.
KanjiMode = 25,
//
// 摘要:
// The ESC key.
Escape = 27,
//
// 摘要:
// The IME convert key.
IMEConvert = 28,
//
// 摘要:
// The IME nonconvert key.
IMENonconvert = 29,
//
// 摘要:
// The IME accept key, replaces System.Windows.Forms.Keys.IMEAceept.
IMEAccept = 30,
//
// 摘要:
// The IME accept key. Obsolete, use System.Windows.Forms.Keys.IMEAccept instead.
IMEAceept = 30,
//
// 摘要:
// The IME mode change key.
IMEModeChange = 31,
//
// 摘要:
// The SPACEBAR key.
Space = 32,
//
// 摘要:
// The PAGE UP key.
Prior = 33,
//
// 摘要:
// The PAGE UP key.
PageUp = 33,
//
// 摘要:
// The PAGE DOWN key.
Next = 34,
//
// 摘要:
// The PAGE DOWN key.
PageDown = 34,
//
// 摘要:
// The END key.
End = 35,
//
// 摘要:
// The HOME key.
Home = 36,
//
// 摘要:
// The LEFT ARROW key.
Left = 37,
//
// 摘要:
// The UP ARROW key.
Up = 38,
//
// 摘要:
// The RIGHT ARROW key.
Right = 39,
//
// 摘要:
// The DOWN ARROW key.
Down = 40,
//
// 摘要:
// The SELECT key.
Select = 41,
//
// 摘要:
// The PRINT key.
Print = 42,
//
// 摘要:
// The EXECUTE key.
Execute = 43,
//
// 摘要:
// The PRINT SCREEN key.
Snapshot = 44,
//
// 摘要:
// The PRINT SCREEN key.
PrintScreen = 44,
//
// 摘要:
// The INS key.
Insert = 45,
//
// 摘要:
// The DEL key.
Delete = 46,
//
// 摘要:
// The HELP key.
Help = 47,
//
// 摘要:
// The 0 key.
D0 = 48,
//
// 摘要:
// The 1 key.
D1 = 49,
//
// 摘要:
// The 2 key.
D2 = 50,
//
// 摘要:
// The 3 key.
D3 = 51,
//
// 摘要:
// The 4 key.
D4 = 52,
//
// 摘要:
// The 5 key.
D5 = 53,
//
// 摘要:
// The 6 key.
D6 = 54,
//
// 摘要:
// The 7 key.
D7 = 55,
//
// 摘要:
// The 8 key.
D8 = 56,
//
// 摘要:
// The 9 key.
D9 = 57,
//
// 摘要:
// The A key.
A = 65,
//
// 摘要:
// The B key.
B = 66,
//
// 摘要:
// The C key.
C = 67,
//
// 摘要:
// The D key.
D = 68,
//
// 摘要:
// The E key.
E = 69,
//
// 摘要:
// The F key.
F = 70,
//
// 摘要:
// The G key.
G = 71,
//
// 摘要:
// The H key.
H = 72,
//
// 摘要:
// The I key.
I = 73,
//
// 摘要:
// The J key.
J = 74,
//
// 摘要:
// The K key.
K = 75,
//
// 摘要:
// The L key.
L = 76,
//
// 摘要:
// The M key.
M = 77,
//
// 摘要:
// The N key.
N = 78,
//
// 摘要:
// The O key.
O = 79,
//
// 摘要:
// The P key.
P = 80,
//
// 摘要:
// The Q key.
Q = 81,
//
// 摘要:
// The R key.
R = 82,
//
// 摘要:
// The S key.
S = 83,
//
// 摘要:
// The T key.
T = 84,
//
// 摘要:
// The U key.
U = 85,
//
// 摘要:
// The V key.
V = 86,
//
// 摘要:
// The W key.
W = 87,
//
// 摘要:
// The X key.
X = 88,
//
// 摘要:
// The Y key.
Y = 89,
//
// 摘要:
// The Z key.
Z = 90,
//
// 摘要:
// The left Windows logo key (Microsoft Natural Keyboard).
LWin = 91,
//
// 摘要:
// The right Windows logo key (Microsoft Natural Keyboard).
RWin = 92,
//
// 摘要:
// The application key (Microsoft Natural Keyboard).
Apps = 93,
//
// 摘要:
// The computer sleep key.
Sleep = 95,
//
// 摘要:
// The 0 key on the numeric keypad.
NumPad0 = 96,
//
// 摘要:
// The 1 key on the numeric keypad.
NumPad1 = 97,
//
// 摘要:
// The 2 key on the numeric keypad.
NumPad2 = 98,
//
// 摘要:
// The 3 key on the numeric keypad.
NumPad3 = 99,
//
// 摘要:
// The 4 key on the numeric keypad.
NumPad4 = 100,
//
// 摘要:
// The 5 key on the numeric keypad.
NumPad5 = 101,
//
// 摘要:
// The 6 key on the numeric keypad.
NumPad6 = 102,
//
// 摘要:
// The 7 key on the numeric keypad.
NumPad7 = 103,
//
// 摘要:
// The 8 key on the numeric keypad.
NumPad8 = 104,
//
// 摘要:
// The 9 key on the numeric keypad.
NumPad9 = 105,
//
// 摘要:
// The multiply key.
Multiply = 106,
//
// 摘要:
// The add key.
Add = 107,
//
// 摘要:
// The separator key.
Separator = 108,
//
// 摘要:
// The subtract key.
Subtract = 109,
//
// 摘要:
// The decimal key.
Decimal = 110,
//
// 摘要:
// The divide key.
Divide = 111,
//
// 摘要:
// The F1 key.
F1 = 112,
//
// 摘要:
// The F2 key.
F2 = 113,
//
// 摘要:
// The F3 key.
F3 = 114,
//
// 摘要:
// The F4 key.
F4 = 115,
//
// 摘要:
// The F5 key.
F5 = 116,
//
// 摘要:
// The F6 key.
F6 = 117,
//
// 摘要:
// The F7 key.
F7 = 118,
//
// 摘要:
// The F8 key.
F8 = 119,
//
// 摘要:
// The F9 key.
F9 = 120,
//
// 摘要:
// The F10 key.
F10 = 121,
//
// 摘要:
// The F11 key.
F11 = 122,
//
// 摘要:
// The F12 key.
F12 = 123,
//
// 摘要:
// The F13 key.
F13 = 124,
//
// 摘要:
// The F14 key.
F14 = 125,
//
// 摘要:
// The F15 key.
F15 = 126,
//
// 摘要:
// The F16 key.
F16 = 127,
//
// 摘要:
// The F17 key.
F17 = 128,
//
// 摘要:
// The F18 key.
F18 = 129,
//
// 摘要:
// The F19 key.
F19 = 130,
//
// 摘要:
// The F20 key.
F20 = 131,
//
// 摘要:
// The F21 key.
F21 = 132,
//
// 摘要:
// The F22 key.
F22 = 133,
//
// 摘要:
// The F23 key.
F23 = 134,
//
// 摘要:
// The F24 key.
F24 = 135,
//
// 摘要:
// The NUM LOCK key.
NumLock = 144,
//
// 摘要:
// The SCROLL LOCK key.
Scroll = 145,
//
// 摘要:
// The left SHIFT key.
LShiftKey = 160,
//
// 摘要:
// The right SHIFT key.
RShiftKey = 161,
//
// 摘要:
// The left CTRL key.
LControlKey = 162,
//
// 摘要:
// The right CTRL key.
RControlKey = 163,
//
// 摘要:
// The left ALT key.
LMenu = 164,
//
// 摘要:
// The right ALT key.
RMenu = 165,
//
// 摘要:
// The browser back key.
BrowserBack = 166,
//
// 摘要:
// The browser forward key.
BrowserForward = 167,
//
// 摘要:
// The browser refresh key.
BrowserRefresh = 168,
//
// 摘要:
// The browser stop key.
BrowserStop = 169,
//
// 摘要:
// The browser search key.
BrowserSearch = 170,
//
// 摘要:
// The browser favorites key.
BrowserFavorites = 171,
//
// 摘要:
// The browser home key.
BrowserHome = 172,
//
// 摘要:
// The volume mute key.
VolumeMute = 173,
//
// 摘要:
// The volume down key.
VolumeDown = 174,
//
// 摘要:
// The volume up key.
VolumeUp = 175,
//
// 摘要:
// The media next track key.
MediaNextTrack = 176,
//
// 摘要:
// The media previous track key.
MediaPreviousTrack = 177,
//
// 摘要:
// The media Stop key.
MediaStop = 178,
//
// 摘要:
// The media play pause key.
MediaPlayPause = 179,
//
// 摘要:
// The launch mail key.
LaunchMail = 180,
//
// 摘要:
// The select media key.
SelectMedia = 181,
//
// 摘要:
// The start application one key.
LaunchApplication1 = 182,
//
// 摘要:
// The start application two key.
LaunchApplication2 = 183,
//
// 摘要:
// The OEM Semicolon key on a US standard keyboard.
OemSemicolon = 186,
//
// 摘要:
// The OEM 1 key.
Oem1 = 186,
//
// 摘要:
// The OEM plus key on any country/region keyboard.
Oemplus = 187,
//
// 摘要:
// The OEM comma key on any country/region keyboard.
Oemcomma = 188,
//
// 摘要:
// The OEM minus key on any country/region keyboard.
OemMinus = 189,
//
// 摘要:
// The OEM period key on any country/region keyboard.
OemPeriod = 190,
//
// 摘要:
// The OEM question mark key on a US standard keyboard.
OemQuestion = 191,
//
// 摘要:
// The OEM 2 key.
Oem2 = 191,
//
// 摘要:
// The OEM tilde key on a US standard keyboard.
Oemtilde = 192,
//
// 摘要:
// The OEM 3 key.
Oem3 = 192,
//
// 摘要:
// The OEM open bracket key on a US standard keyboard.
OemOpenBrackets = 219,
//
// 摘要:
// The OEM 4 key.
Oem4 = 219,
//
// 摘要:
// The OEM pipe key on a US standard keyboard.
OemPipe = 220,
//
// 摘要:
// The OEM 5 key.
Oem5 = 220,
//
// 摘要:
// The OEM close bracket key on a US standard keyboard.
OemCloseBrackets = 221,
//
// 摘要:
// The OEM 6 key.
Oem6 = 221,
//
// 摘要:
// The OEM singled/double quote key on a US standard keyboard.
OemQuotes = 222,
//
// 摘要:
// The OEM 7 key.
Oem7 = 222,
//
// 摘要:
// The OEM 8 key.
Oem8 = 223,
//
// 摘要:
// The OEM angle bracket or backslash key on the RT 102 key keyboard.
OemBackslash = 226,
//
// 摘要:
// The OEM 102 key.
Oem102 = 226,
//
// 摘要:
// The PROCESS KEY key.
ProcessKey = 229,
//
// 摘要:
// Used to pass Unicode characters as if they were keystrokes. The Packet key value
// is the low word of a 32-bit virtual-key value used for non-keyboard input methods.
Packet = 231,
//
// 摘要:
// The ATTN key.
Attn = 246,
//
// 摘要:
// The CRSEL key.
Crsel = 247,
//
// 摘要:
// The EXSEL key.
Exsel = 248,
//
// 摘要:
// The ERASE EOF key.
EraseEof = 249,
//
// 摘要:
// The PLAY key.
Play = 250,
//
// 摘要:
// The ZOOM key.
Zoom = 251,
//
// 摘要:
// A constant reserved for future use.
NoName = 252,
//
// 摘要:
// The PA1 key.
Pa1 = 253,
//
// 摘要:
// The CLEAR key.
OemClear = 254,
//
// 摘要:
// The bitmask to extract a key code from a key value.
KeyCode = 65535,
//
// 摘要:
// The SHIFT modifier key.
Shift = 65536,
//
// 摘要:
// The CTRL modifier key.
Control = 131072,
//
// 摘要:
// The ALT modifier key.
Alt = 262144
}
}