I have defined LVITEM as follows:
<StructLayout(LayoutKind.Sequential)> Private Structure LVITEM
Dim mask As Int16
Dim iItem As Int16
Dim iSubItem As Int16
Dim state As Int16
Dim stateMask As Int16
<MarshalAs(UnmanagedType.LPWStr)> Dim pszText As IntPtr
Dim cchTextMax As Int16
Dim iImage As Int16
Dim lParam As Integer
Dim iIndent As Int16
End Structure
When I execute the following code I get an exception on the last line:
<code>
Dim lvi As LVITEM
''dwSize = Marshal.SizeOf(lvi) ' This does not work either
dwSize = 24
Dim SysShared As IntPtr
Dim StringMemory As IntPtr
lvi.mask = LVIF_TEXT
lvi.cchTextMax = 100
lvi.iSubItem = 0
SysShared = GetMemSharedNT(lPID, dwSize, hProcess)
StringMemory = GetMemSharedNT(lPID, 100, hProcess)
lvi.pszText = StringMemory
WriteProcessMemory(hProcess, SysShared, lvi, dwSize,
BytesWritten)
</code>
The error I get is
"Can not marshal field pszText of type LVITEM: Invalid managed/unmanaged
type combination (Int/UInt must be paired with I or U)."
I guess that pszText should be defined 'As String', but then I have a
problem making it point to the memory I have allocated.
Does anyone have any idea how to get round this? I have a sample in C from
this site
http://www.codeproject.com/threads/int64_memsteal.asp
but I would really prefer to do the whole thing in VB.NET.
TIA
Charles