Hi,
I'm trying to interop with WinInet.. given this method
HINTERNET HttpOpenRequest(
HINTERNET hConnect,
LPCTSTR lpszVerb,
LPCTSTR lpszObjectName,
LPCTSTR lpszVersion,
LPCTSTR lpszReferer,
LPCTSTR* lpszAcceptTypes,
DWORD dwFlags,
DWORD_PTR dwContext
);
and this prototype
[DllImport("WinInet.dll", CharSet=CharSet.Unicode, SetLastError=true,
CallingConvention=CallingConvention.StdCall)]
public static extern IntPtr HttpOpenRequest(
IntPtr /*HINTERNET*/hConnect,
string /*LPCTSTR*/ lpszVerb,
string /*LPCTSTR*/ lpszObjectName,
string /*LPCTSTR*/ lpszVersion,
string /*LPCTSTR*/ lpszReferrer,
String[] /*LPCTSTR**/lpszAcceptTypes,
UInt32 /*DWORD*/ dwFlags,
IntPtr /*DWORD_PTR*/ dwContext);
Can anyone suggest what I've done wrong (other than trying to do this
in the first place)? When I call it as follows
string[] strArray = {"text/*"} ;
IntPtr hFile2 = WinInet.HttpOpenRequest(hConnect, "GET",
"/Win/hi.txt", "", "",
strArray, Flags.INTERNET_FLAG_KEEP_CONNECTION, IntPtr.Zero);
I get a null ref exception: "Additional information: Object reference
not set to an instance of an object". If I pass null for
lpszAcceptTypes I get a handle, but calling InternetReadFile fails
(InternetReadFile works when I use InternetOpenUrl, so I think it's
ok).
Any help would be greatly appreciated. I've tried many permutations
and internet searches without success.
thanks,
Orlando
Orlando Cardoso - 08 Apr 2004 16:27 GMT
I figured it out.. it had nothing to do with interop.
string[] strArray = {"text/*", null} fixed the error, and I needed an
HttpSendRequest between the open and read to get it to work.
Sorry for the post.
> Hi,
>
[quoted text clipped - 45 lines]
> thanks,
> Orlando