资源描述:
《C# 获取其他程序ListView控件中的内容介绍.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、代码:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingSystem.Runtime.InteropServices;namespace读取其他软件li
2、stview控件的内容{publicpartialclassForm1:Form{inthwnd;//窗口句柄intprocess;//进程句柄intpointer;privateconstuintLVM_FIRST=0x1000;privateconstuintLVM_GETHEADER=LVM_FIRST+31;privateconstuintLVM_GETITEMCOUNT=LVM_FIRST+4;//获取列表行数privateconstuintLVM_GETITEMTEXT=LVM_FIRS
3、T+45;//获取列表内的内容privateconstuintLVM_GETITEMW=LVM_FIRST+75;privateconstuintHDM_GETITEMCOUNT=0x1200;//获取列表列数privateconstuintPROCESS_VM_OPERATION=0x0008;//允许函数VirtualProtectEx使用此句柄修改进程的虚拟内存privateconstuintPROCESS_VM_READ=0x0010;//允许函数访问权限privateconstuintPR
4、OCESS_VM_WRITE=0x0020;//允许函数写入权限privateconstuintMEM_COMMIT=0x1000;//为特定的页面区域分配内存中或磁盘的页面文件中的物理存储privateconstuintMEM_RELEASE=0x8000;privateconstuintMEM_RESERVE=0x2000;//保留进程的虚拟地址空间,而不分配任何物理存储privateconstuintPAGE_READWRITE=4;privateintLVIF_TEXT=0x0001;[Dl
5、lImport("user32.dll")]//查找窗口privatestaticexternintFindWindow(stringstrClassName,//窗口类名stringstrWindowName//窗口标题);[DllImport("user32.dll")]//在窗口列表中寻找与指定条件相符的第一个子窗口privatestaticexternintFindWindowEx(inthwndParent,//handletoparentwindow inthwndChildAfter
6、,//handletochildwindowstringclassName,//窗口类名stringwindowName//窗口标题);[DllImport("user32.DLL")]privatestaticexternintSendMessage(inthWnd,uintMsg,intwParam,intlParam);[DllImport("user32.dll")]//找出某个窗口的创建者(线程或进程),返回创建者的标志符privatestaticexternintGetWindowThr
7、eadProcessId(inthwnd,outintprocessId);[DllImport("kernel32.dll")]//打开一个已存在的进程对象,并返回进程的句柄privatestaticexternintOpenProcess(uintdwDesiredAccess,boolbInheritHandle,intprocessId);[DllImport("kernel32.dll")]//为指定的进程分配内存地址:成功则返回分配内存的首地址privatestaticexternint
8、VirtualAllocEx(inthProcess,IntPtrlpAddress,uintdwSize,uintflAllocationType,uintflProtect);[DllImport("kernel32.dll")]//从指定内存中读取字节集数据privatestaticexternboolReadProcessMemory(inthProcess,//被读取者的进程句柄intlpBaseAddress,//开始读取的内存地址IntPtrlpBuff