Hmm lets see…
you get an error on this? with error code 87?
result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)
result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
MSDN says this..
ERROR_INVALID_PARAMETER
87 (0x57)
The parameter is incorrect.
You have declared the function like this…
Declare Function VirtualFreeEx Lib “kernel32” (ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal dwFreeType As Integer) As Integer
You created variables like this…
Dim pHandle As Integer
Dim pStrBufferMemory As Integer
Dim pMyItemMemory As Integer
MSDN says this about VirtualFreeEx…
Parameters
hProcess [in]
A handle to a process. The function frees memory within the virtual address space of the process.
The handle must have the PROCESS_VM_OPERATION access right. For more information, see Process Security and Access Rights.
lpAddress [in]
A pointer to the starting address of the region of memory to be freed.
If the dwFreeType parameter is MEM_RELEASE, lpAddress must be the base address returned by the VirtualAllocEx function when the region is reserved.
dwSize [in]
The size of the region of memory to free, in bytes.
hmm Parameter lpAddress [in] requires a pointer, pStrBufferMemory As Integer and pMyItemMemory As Integer seems you are passing an integer value and not a pointer?
I could be completely wrong here as I haven’t personally used this code or looked through it properly.