Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the correct way to import IWinInetHttpInfo (COM) in .NET?
    text
    copied!<p>I am having great difficultly importing and using <code>IWinInetHttpInfo</code> (<a href="http://msdn.microsoft.com/en-us/library/ms774972(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms774972(v=vs.85).aspx</a>), a COM interface in .NET.</p> <p>I am in the process of writing an implementation of <code>IDownloadManager</code>, which eventually led me to implement this interface to get some raw headers.</p> <p>This interface has just one method, QueryInfo (see link above). Writing the signature in .NET seems wrong, since I always get the HRESULT 0x80070057 (The Parameter is Incorrect) when I call it.</p> <p>Here's what I have so far:</p> <pre><code>[ComImport, ComVisible(true)] [Guid("79eac9d8-bafa-11ce-8c82-00aa004ba90b")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [CLSCompliant(false)] public interface IWinInetHttpInfo { [return: MarshalAs(UnmanagedType.I4)] [PreserveSig] int QueryInfo( [In, MarshalAs(UnmanagedType.U4)] UInt32 dwOption, IntPtr pBuffer, [In, Out, MarshalAs(UnmanagedType.U4)] ref UInt32 pcbBuf, [In, Out, MarshalAs(UnmanagedType.U4)] ref UInt32 pdwFlags, [In, Out, MarshalAs(UnmanagedType.U4)] ref UInt32 pdwReserved); } </code></pre> <p>I have a feeling that the signature I have above is wrong, but I've no clue on how to resolve it. Any guidance would be greatly appreciated.</p> <p>EDIT: Here's sample usage:</p> <pre><code>IWinInetHttpInfo spWinInetHttpInfo = (IWinInetHttpInfo)m_pBinding; //this cast causes queryinterface to be called if (spWinInetHttpInfo != null) { uint size = 0; //sizeof(DWORD) uint flags = 0; //Get all headers uint ignore = 0; int hrTemp = spWinInetHttpInfo.QueryInfo(Constants.HTTP_QUERY_RAW_HEADERS_CRLF, IntPtr.Zero, ref size, ref flags, ref ignore); //we get here, but hrTemp == 0x80070057 } </code></pre> <p>Add'l info:</p> <p>I'm trying to port the OnProgress method writting in C++ here: <a href="http://code.google.com/p/webknowledge/source/browse/trunk/csExWB/ComUtilities/ComUtilities/UtilMan.cpp?r=7" rel="nofollow">http://code.google.com/p/webknowledge/source/browse/trunk/csExWB/ComUtilities/ComUtilities/UtilMan.cpp?r=7</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload