资源简介
C#取得SysListView32所有行(包括列表头)的内容源代码,用用例可运行
代码片段和文件信息
/* 用例
private void button1_Click(object sender EventArgs e)
{
IntPtr intPtr;
intPtr = GetWindowsTaskSysListView32Ptr();//取任务管理器ListView句柄
List> list = SysListView32.GetRowList(intPtr);
string text = SysListView32.GetText(list);
MessageBox.Show(text);
//List columnsText= SysListView32.GetColumnsHeaderText(intPtr);
//string text= CoreUtil.GetText(columnsText p => p+“\r\n“);
// AutoCloseDialog.Show(text);
}
static IntPtr GetWindowsTaskSysListView32Ptr()//运行时打开任务管理器
{
IntPtr intPtr = SysListView32.FindWindow(“#32770“ “Windows 任务管理器“);
intPtr = SysListView32.FindWindowEx(intPtr IntPtr.Zero “#32770“ null);
intPtr = SysListView32.FindWindowEx(intPtr IntPtr.Zero “SysListView32“ null);
return intPtr;
}
*/
public static class SysListView32
{
#region
const uint LVM_FIRST = 0x1000;
const uint LVM_GETITEMCOUNT = LVM_FIRST + 4;
const uint LVM_GETITEMW = LVM_FIRST + 75;
const uint MEM_COMMIT = 0x1000;
const uint MEM_RELEASE = 0x8000;
const uint MEM_RESERVE = 0x2000;
const uint PAGE_READWRITE = 4;
const int HDI_TEXT = 2;
const int LVIF_TEXT = 0x0001;
const uint PROCESS_VM_OPERATION = 0x0008;
const uint PROCESS_VM_READ = 0x0010;
const uint PROCESS_VM_WRITE = 0x0020;
[DllImport(“user32.DLL“)]
static extern int SendMessage(IntPtr hWnd uint Msg int wParam int lParam);
[DllImport(“user32.DLL“)]
public static extern IntPtr FindWindow(string lpszClass string lpszWindow);
[DllImport(“user32.DLL“)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent
IntPtr hwndChildAfter string lpszClass string lpszWindow);
[DllImport(“user32.dll“)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd
out uint dwProcessId);
[DllImport(“kernel32.dll“)]
public static extern IntPtr OpenProcess(uint dwDesiredAccess
bool bInheritHandle uint dwProcessId);
[DllImport(“kernel32.dll“)]
static extern IntPtr VirtualAllocEx(IntPtr hProcess IntPtr lpAddress
uint dwSize uint flAllocationType uint flProtect);
[DllImport(“kernel32.dll“)]
static extern bool VirtualFreeEx(IntPtr hProcess IntPtr lpAddress
uint dwSize uint dwFreeType);
[DllImport(“kernel32.dll“)]
static extern bool CloseHandle(IntPtr handle);
[DllImport(“kernel32.dll“)]
static extern bool WriteProcessMemory(IntPtr hProcess IntPtr lpbaseAddress
IntPtr lpBuffer int nSize ref uint vNumberOfBytesRead);
[DllImport(“kernel32.dll“)]
static extern bo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 10157 2019-03-18 06:40 SysListView32.cs
----------- --------- ---------- ----- ----
10157 1
评论
共有 条评论