Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2004

Tip: Looking for answers? Try searching our database.

Problem with Winet/HttpOpenRequest & Interop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Orlando Cardoso - 08 Apr 2004 03:09 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.