var pItem: TLVItem;<br> Buff: PChar;<br> PID,PRC: THandle;<br> R: Cardinal;<br>begin<br> GetWindowThreadProcessId(L, @PID);<br> PRC := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or <br> PROCESS_VM_WRITE, False, PID);<br> Buff := VirtualAllocEx(PRC, nil, 4096, MEM_RESERVE or MEM_COMMIT, <br> PAGE_READWRITE);<br> ZeroMemory(@pItem,SizeOf(pItem));<br> with pItem do<br> begin<br> mask := LVIF_TEXT;<br> pszText := PChar(integer(Buff) + SizeOf(pItem) * 4);<br> cchTextMax := Length(Edit1.Text)+1;//Edit1.Text為新增Item名稱<br> end;<br> WriteProcessMemory(PRC, Buff, @pItem, Sizeof(pItem), R);<br> WriteProcessMemory(PRC, PChar(integer(Buff) + SizeOf(pItem) * 4), <br> PChar(Edit1.Text), Length(Edit1.Text)+1, R);<br> SendMessage(L,LVM_INSERTITEM,0,LongInt(Buff));//L為ListView的Handle<br> VirtualFreeEx(PRC, Buff, 0, MEM_RELEASE);<br> CloseHandle(PRC);<br>end;