PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 [RESOLVED] error on proxy-VBForums
Results 1 to 6 of 6

Thread: [RESOLVED] error on proxy

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    242

    Resolved [RESOLVED] error on proxy

    struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
    struct_IPI.proxy = System.Runtime.InteropServices.Marshal.StringToHGl obalAnsi(strProxy)
    struct_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGl obalAnsi("local")

    ' 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...
    Attached Images Attached Images  
    < advertising link removed by moderator >

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: error on proxy

    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.

    vb Code:
    1. ' This is our 'Test' structure
    2.     <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)>
    3.     Structure Test
    4.         Dim A As Integer
    5.         <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Dim B As String ' 32 bytes
    6.     End Structure ' Length = 32 + 4 = 40 bytes
    7.  
    8.     ' This will convert a structure into a byte array:
    9.     Function StrToByteArray(ByVal Struct As Test) As Byte()
    10.         Dim datalen As Integer = Marshal.SizeOf(Struct)
    11.         Dim ptr As IntPtr = Marshal.AllocHGlobal(datalen)
    12.         Dim bytearray(datalen - 1) As Byte
    13.         Marshal.StructureToPtr(Struct, ptr, False)
    14.         Marshal.Copy(ptr, bytearray, 0, datalen)
    15.         'Important:
    16.         Marshal.FreeHGlobal(ptr)
    17.         Return bytearray
    18.     End Function
    19.  
    20.     ' This will convert a byte array into a structure:
    21.     Function ByteArrayToStr(ByVal bytearray() As Byte) As Test
    22.         Dim gch = GCHandle.Alloc(bytearray, GCHandleType.Pinned)
    23.         Dim ptr As IntPtr = gch.AddrOfPinnedObject
    24.         Dim struct As Test = CType(Marshal.PtrToStructure(ptr, GetType(Test)), Test)
    25.         'Important:
    26.         gch.Free()
    27.         Return struct
    28.     End Function

  3. #3
    Frenzied Member Pc_Not_Mac's Avatar
    Join Date
    Oct 2009
    Location
    localhost
    Posts
    1,206

    Re: error on proxy

    Can you please re size your picture?
    My Codebank:
    Windows Vista & 7 Glass Effect & Limit the amount of times your application could be opened.
    Pause Your Code & Check the OS name

    The question of whether computers can think is like the question of whether submarines can swim.

    Currently learning: Java

    Coding can be a learning experience or

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    242

    Re: error on proxy

    how u mean pc_not_Mac
    < advertising link removed by moderator >

  5. #5
    Frenzied Member Pc_Not_Mac's Avatar
    Join Date
    Oct 2009
    Location
    localhost
    Posts
    1,206

    Re: error on proxy

    how u mean pc_not_Mac
    I think by showing us the errors.
    And showing us the code.
    Helps us more then just a picture.
    My Codebank:
    Windows Vista & 7 Glass Effect & Limit the amount of times your application could be opened.
    Pause Your Code & Check the OS name

    The question of whether computers can think is like the question of whether submarines can swim.

    Currently learning: Java

    Coding can be a learning experience or

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    242

    Re: error on proxy

    sorry i just wanted to show which parts are showing the error
    < advertising link removed by moderator >

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width