Error in Calling HttpQueryInfo() in VB.Net application

G

Guest

I have a VB6 application which calls HttpQueryInfo() with the following call:
HttpQueryInfo(hHttpRequest, iInfoLevel, sBuffer.Value, lBufferLength, 0)
where hHttpRequest, iInfoLevel and lBufferLength are all integers, and
httpQueryInfo is declared as:
Public Declare Function HttpQueryInfo Lib "wininet.dll" Alias
"HttpQueryInfoA"(ByVal hHttpRequest As Integer, ByVal lInfoLevel As Integer,
ByRef sBuffer As Any, ByRef lBufferLength As Integer, ByRef lIndex As
Integer) As Short
After converting to VB.Net, this declaration generated the following error:
"'As Any' is not supported is not supported in declare statements", with the
following upgrade note:
'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click for
more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1016"'
The documentation of this upgrade issue states that you should determine the
type that is actually being passed, and make the declaration accordingly. In
my application, this parameter (sBuffer) is being passed both as a string and
as an integer, so I changed the declaration to use an object, i.e.:
Public Declare Function HttpQueryInfo Lib "wininet.dll" Alias
"HttpQueryInfoA" (ByVal hHttpRequest As Integer, ByVal lInfoLevel As Integer,
ByRef oBuffer As Object, ByRef lBufferLength As Integer, ByRef lIndex As
Integer) As Short
I try and call this routine and pass a string with the following code:
Dim sBuffer As New VB6.FixedLengthString(1024)
Dim lBufferLength As Integer

lBufferLength = Len(sBuffer.Value)
GetQueryInfoString = CBool(HttpQueryInfo(hHttpRequest, iInfoLevel,
sBuffer.Value, lBufferLength, 0))
When I do this, I get the following error:
"An unhandled exception of type
'System.Runtime.InteropServices.InvalidOLEVariantTypeException' occurred in
Project1.exe.
Additional Information: Specified OLE variant is invalid"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top