首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

vb6断开网络改成vb2010后出错,还请高手帮助看看,多谢!

2012-02-08 
vb6断开网络改成vb2010后出错,还请高手帮助看看,谢谢!!!vb6:VB codeOption ExplicitPrivate Declare Funct

vb6断开网络改成vb2010后出错,还请高手帮助看看,谢谢!!!
vb6:

VB code
Option ExplicitPrivate Declare Function RasHangUp Lib "RasApi32.DLL" Alias "RasHangUpA" (ByVal hRasConn As Long) As LongPrivate Declare Function RasEnumConnections Lib "RasApi32.DLL" Alias "RasEnumConnectionsA" (lprasconn As Any, lpcb As Long, lpcConnections As Long) As LongConst RAS_MaxEntryName = 256Const RAS_MaxDeviceName = 128Const RAS_MaxDeviceType = 16dwSize As LonghRasConn As LongszEntryName(RAS_MaxEntryName) As ByteszDeviceType(RAS_MaxDeviceType) As ByteszDeviceName(RAS_MaxDeviceName) As ByteEnd TypePrivate Sub Command1_Click()Dim lngRetCode As LongDim lpcb As LongDim lpcConnections As LongDim intArraySize As IntegerDim intLooper As IntegerReDim lprasconn95(intArraySize) As RASCONN95lprasconn95(0).dwSize = 412lpcb = 256 * lprasconn95(0).dwSizelngRetCode = RasEnumConnections(lprasconn95(0), lpcb, lpcConnections)If lngRetCode = 0 ThenIf lpcConnections > 0 ThenFor intLooper = 0 To lpcConnections - 1RasHangUp lprasconn95(intLooper).hRasConnNext intLooperElseMsgBox "没有拨号网络连接!", vbInformationEnd IfEnd IfEnd Sub



vb2010:
VB.NET code
Imports System.Runtime.InteropServicesPublic Class Form2    Public Const RAS_MaxEntryName As Int32 = 256    Public Const RAS_MaxPhoneNumber As Int32 = 128    Public Const RAS_MaxCallbackNumber As Int32 = 128    Public Const RAS_MaxUserName As Int32 = 256    Public Const RAS_MaxPassword As Int32 = 256    Public Const RAS_MaxDomain As Int32 = 15    Public Const RAS_MaxDeviceType = 16    Private Structure RASCONN95        Public dwSize As Integer        Public hRasConn As Integer        <VBFixedArray(RAS_MaxEntryName)> Public szEntryName As Byte        <VBFixedArray(RAS_MaxDeviceType)> Public szDeviceType As Byte        <VBFixedArray(RAS_MaxUserName)> Public szDeviceName As Byte    End Structure    Dim lprasconn95(0) As RASCONN95    Public Declare Auto Function RasGetEntryDialParams Lib "rasapi32.dll" (ByVal PhoneBook As String, ByRef DialParams As RASDIALPARAMS, ByRef Password As Int32) As Int32    Public Declare Unicode Function RasDial Lib "rasapi32.dll" Alias "RasDialW" (ByVal RasDialExtensions As Int32, ByVal PhoneBook As String, ByRef DialParams As RASDIALPARAMS, ByVal NotifierType As Int32, ByVal Notifier As Int32, ByRef hRasConnection As Int32) As Int32    Private Declare Function RasEnumConnections Lib "RasApi32.DLL" Alias "RasEnumConnectionsA" (ByVal lprasconn As Object, ByVal lpcb As Integer, ByVal lpcConnections As Integer) As Integer    Private Declare Function RasHangUp Lib "RasApi32.DLL" Alias "RasHangUpA" (ByVal hRasConn As Integer) As Integer       Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click        Dim lngRetCode As Integer        Dim lpcb As Integer        Dim lpcConnections As Integer        Dim intArraySize As Integer        Dim intLooper As Integer        ReDim lprasconn95(intArraySize)        lprasconn95(0).dwSize = 412        lpcb = 256 * lprasconn95(0).dwSize        '**************(↓)这一行(↓)**************        lngRetCode = RasEnumConnections(lprasconn95(0), lpcb, lpcConnections)'出错        '**************(↑)这一行(↑)**************        If lngRetCode = 0 Then            If lpcConnections > 0 Then                For intLooper = 0 To lpcConnections - 1                    RasHangUp(lprasconn95(intLooper).hRasConn)                Next intLooper            Else                MsgBox("没有拨号网络连接!", vbInformation)            End If        End If    End SubEnd Class


------解决方案--------------------


贴个能编译通过的来。RASDIALPARAMS声明没看到。

热点排行