我通过C#调用的wininet.dll的API,并在InternetCloseHandle执行之前想进行查询,但是总是乱码。[DllImport("wininet.dll",
            CharSet = CharSet.Ansi,
            SetLastError = true,
            CallingConvention = CallingConvention.StdCall)]
        static extern bool HttpQueryInfo(
            IntPtr hRequest,
            uint dwInfoLevel,
            ref IntPtr lpvBuffer,
            ref int lpdwBufferLength,
            ref uint lpdwIndex);int buffer_length = 10240;
                byte[] cookies_buffer = new byte[buffer_length];                IntPtr i_buffer = Marshal.AllocHGlobal(buffer_length);
                //查询
                HttpQueryInfo(hInternet, 22 | 0x80000000, ref i_buffer, ref cookies_buffer_length, ref lpdwIndex);
                //这里copy后保存的文件总是乱码
                Marshal.Copy(i_buffer, cookies_buffer, 0, cookies_buffer_length);
                File.WriteAllBytes("d:/buffer.txt", cookies_buffer);其中:
我查询代码19(HTTP_QUERY_STATUS_CODE)的时候,看到cookies_buffer_length为4.
我查询代码22 | 0x80000000(HTTP_QUERY_RAW_HEADERS_CRLF | HTTP_QUERY_FLAG_REQUEST_HEADERS)的时候,看到cookies_buffer_length大概都是400~600。
从query得到的buffer长度看来,应该是有值的,
谢谢