检测到 PInvokeStackImbalance - Visual Basic 2010 [英] PInvokeStackImbalance was detected - Visual Basic 2010

查看:25
本文介绍了检测到 PInvokeStackImbalance - Visual Basic 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做一个互联网检查器,但我不知道这个 PinvokeStackImbalance 有什么问题.实际上,代码是为 Visual Basic 2008 编写的,但我使用的是 Visual Basic 2010.

I want to make an internet checker , but I don't know what's the problem with this PinvokeStackImbalance. Actually, the code was made for Visual Basic 2008, But I`m using Visual Basic 2010.

WebTest = CBool​​(InternetGetConnectedState(dwflags, 0&))

WebTest = CBool(InternetGetConnectedState(dwflags, 0&))

问题出在哪里?顺便说一句,这是一个模块.

Where's the problem? Btw, it's a module.

推荐答案

当您对函数使用错误的声明时,您将收到 MDA 警告.这在 VB.NET 中很常见,互联网上有很多旧的 VB6 声明在 VB.NET 中不起作用.一个明显的问题是这个特殊的函数,它需要两个 DWORD 类型的参数,如果你在声明中看到 Long ,那么你的 VB6 是一个错误的.

You will get that MDA warning when you used a bad declaration for the function. Which is pretty common in VB.NET, there are a lot of old VB6 declarations floating around on the Internet that will not work in VB.NET. A sure sign of trouble is this particular function, it takes two arguments of type DWORD, if you see Long in the declaration then you've got a bad VB6 one.

从 Pinvoke Interop Assistant 工具或 pinvoke.net 网站获取合理可靠的声明:

Get reasonably reliable declarations from the Pinvoke Interop Assistant tool or the pinvoke.net web site:

Private Declare Function InternetGetConnectedState Lib "wininet.dll" _
                     (ByRef lpdwFlags As Int32, ByVal dwReserved As Int32) As Boolean

Private Enum ConnectionStates
    Modem = &H1
    LAN = &H2
    Proxy = &H4
    RasInstalled = &H10
    Offline = &H20
    Configured = &H40
End Enum

这篇关于检测到 PInvokeStackImbalance - Visual Basic 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆