' Allocating memory
Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTask Mem(System.Runtime.InteropServices.Marshal.SizeOf( struct_IPI))
' Converting structure to IntPtr
System.Runtime.InteropServices.Marshal.StructureTo(Ptr(struct_IPI, intptrStruct, True))
Dim iReturn As Boolean = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(stru ct_IPI))
End Sub
#End Region
Where here i have the mistake because makes it error here in image that shows the error...
You have many typos here. But in case you need it, here's an example of marshaling structures into byte array and back:
If you only need a pointer then do not perform Marshal.Copy.
And don't forget to release the memory once you've done or it leaks.
In order to have a 'serializable' structure it should have:
a) <StructLayout(LayoutKind.Sequential> attribute and you must provide Charset (if you have strings Ansi/Unicode).
b) Each string value should be of 'fixed length' which is declared using <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=xx)> where xx is the length of the string.