Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

API wininet PInvokeStackImbalance

Status
Not open for further replies.

tuzojazz

Programmer
Dec 26, 2005
58
MX
Hi:

I'm trying to call "InternetOpenA" function which is in "wininet.dll"

This is my code
Code:
'Declaration of API

Declare Auto Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
   (ByVal sAgent As String, ByVal lAccessType As Long, _
    ByVal sProxyName As String, _
    ByVal sProxyBypass As String, _
    ByVal lFlags As Long) As Long


'the code which calls the function
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Const INTERNET_OPEN_TYPE_PRECONFIG = 0
        Dim hOpen As Long
        hOpen = InternetOpen(vbNullString, _
                INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, _
                vbNullString, 0)
    End Sub
An I get the next error when I call InternetOpen function

A call to PInvoke function 'appApi!appApi.Form1::InternetOpen' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

The code works on vb 6.0 but it does not in vb.net

I also tried declare InternetOpen function in this way

Code:
<DllImport("wininet.dll")> _
   Public Shared Function InternetOpen(ByVal sAgent As String, _
   ByVal lAccessType As Long, _
        ByVal sProxyName As String, _
        ByVal sProxyBypass As String, _
       ByVal lFlags As Integer) As Integer
    End Function
but I get the same error

what would be wrong?

I'm programming in vb.net 2005
net framework 3.0
windows xp sp2

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top