LVITEM lvitem, *plvitem;
char ItemBuf[512],*pItem;plvitem=(LVITEM*)VirtualAllocEx(hProcess, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE);
pItem=(char*)VirtualAllocEx(hProcess, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvitem.cchTextMax=512;
lvitem.iSubItem=0; //ProcessName
lvitem.pszText=pItem;帮我解释一下;谢谢!(我特菜)
char ItemBuf[512],*pItem;plvitem=(LVITEM*)VirtualAllocEx(hProcess, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE);
pItem=(char*)VirtualAllocEx(hProcess, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvitem.cchTextMax=512;
lvitem.iSubItem=0; //ProcessName
lvitem.pszText=pItem;帮我解释一下;谢谢!(我特菜)
ItemBuf[512]是char数组,*pItem是这个数组的指针?pItem=(char*)VirtualAllocEx(hProcess, NULL, 512, MEM_COMMIT, PAGE_READWRITE);
为pItem分配内存?
那能这样 lvitem.pszText=pItem;付值?
vc.net中的定义如下:
typedef struct _LVITEM {
UINT mask;
int iItem;
int iSubItem;
UINT state;
UINT stateMask;
LPTSTR pszText;
int cchTextMax;
int iImage;
LPARAM lParam;
int iIndent;
int iGroupId;
UINT cColumns; // tile view columns
PUINT puColumns;
} LVITEM, *LPLVITEM; lvitem.pszText=pItem;这样附值是什么意思?
LVITEM *plvitem;
Mashal.StructureToPtr
即可,具体可参看靠帮助例子:
LVITEM lvitem = new LVITEM();
...
IntPtr ptr = Mashal.AllowHGlobal(Mashal.SizeoOf(lvitem));
Mashal.StructureToPtr(lvitem, ptr, true);
//lvitem 为LVITEM实例
//*plvitem 为LVITEM类型的指针
char ItemBuf[512],*pItem;
//ItemBuf[512] 为声明512长度的char数组
//pItem char型指针plvitem=(LVITEM*)VirtualAllocEx(hProcess, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE);
//申请一段内存把plvitem指向分配的内存
pItem=(char*)VirtualAllocEx(hProcess, NULL, 512, MEM_COMMIT, PAGE_READWRITE);
//同上lvitem.cchTextMax=512;
lvitem.iSubItem=0; //ProcessName
lvitem.pszText=pItem;
//给lvitem机构类成员赋值
http://community.csdn.net/Expert/topic/4957/4957289.xml?temp=.1589624
已经帮你写了一个代码你可以自己编译来看看就知道是怎么回事了如果还有什么不明白的,可以给我留言