方法1: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Runtime.InteropServices; namespace Backup { /// <summary> /// Window1.xaml 的交互逻辑 /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { System.Diagnostics.Debug.Print("【】【】【】BEGIN【】【】【】【"); IntPtr vHandle = FindWindow("Shell_TrayWnd", null); vHandle = FindWindowEx(vHandle, IntPtr.Zero, "ReBarWindow32", null); vHandle = FindWindowEx(vHandle, IntPtr.Zero, "MSTaskSwWClass", null); vHandle = FindWindowEx(vHandle, IntPtr.Zero, "ToolbarWindow32", null); int vCount = SendMessage(vHandle, TB_BUTTONCOUNT, 0, 0); uint vProcessId; GetWindowThreadProcessId(vHandle, out vProcessId); IntPtr vProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, false, vProcessId); IntPtr vPointer = VirtualAllocEx(vProcess, IntPtr.Zero, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); char[] vBuffer = new char[256]; uint vNumberOfBytesRead = 0; try { for (int i = 0; i < vCount; i++) { SendMessage(vHandle, TB_GETBUTTONTEXTW, i, vPointer.ToInt32()); ReadProcessMemory(vProcess, vPointer, Marshal.UnsafeAddrOfPinnedArrayElement(vBuffer, 0), vBuffer.Length * sizeof(char), ref vNumberOfBytesRead);