| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1660 人关注过本帖
标题:高手指点把下面list显示拨号状态,改为状态栏显示应怎么改革者
取消只看楼主 加入收藏
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
结帖率:47.37%
收藏
已结贴  问题点数:20 回复次数:1 
高手指点把下面list显示拨号状态,改为状态栏显示应怎么改革者
Option Explicit

Public hRasConn As Long '定义一个指向RAS调用的全局句柄
Public Const APINULL = 0&
Public Const UNLEN = 256
Public Const DNLEN = 15
Public Const PWLEN = 256
Public Const RAS95_MaxPhoneNumber = 128
Public Const RAS95_MaxEntryName = 256
Private Const RAS_MaxDeviceType = 16
Private Const RAS95_MaxDeviceName = 128
Public Const RAS95_MaxCallbackNumber = RAS95_MaxPhoneNumber
Public Type RASCONN95
    dwSize As Long
    hRasConn As Long
    szEntryName(RAS95_MaxEntryName) As Byte
    szDeviceType(RAS_MaxDeviceType) As Byte
    szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Public Type RASENTRYNAME95
    dwSize As Long
    szEntryName(RAS95_MaxEntryName) As Byte
End Type
Public Type RASDIALPARAMS95
    dwSize As Long
    szEntryName(RAS95_MaxEntryName) As Byte
    szPhoneNumber(RAS95_MaxPhoneNumber) As Byte
    szCallbackNumber(RAS95_MaxCallbackNumber) As Byte
    szUserName(UNLEN) As Byte
    szPassword(PWLEN) As Byte
    szDomain(DNLEN) As Byte
End Type
'**********************************
'* RAS调用错误代号 *
'**********************************
Public Const NOT_SUPPORTED = 120&
Public Const RASBASEERROR = 600&
Public Const SUCCESS = 0&
Public Const ERROR_PORT_ALREADY_OPEN = (RASBASEERROR + 2)
Public Const ERROR_UNKNOWN = (RASBASEERROR + 35)
Public Const ERROR_REQUEST_TIMEOUT = (RASBASEERROR + 38)
Public Const ERROR_PASSWD_EXPIRED = (RASBASEERROR + 48)
Public Const ERROR_NO_DIALIN_PERMISSION = (RASBASEERROR + 49)
Public Const ERROR_SERVER_NOT_RESPONDING = (RASBASEERROR + 50)
Public Const ERROR_UNRECOGNIZED_RESPONSE = (RASBASEERROR + 52)
Public Const ERROR_NO_RESPONSES = (RASBASEERROR + 60)
Public Const ERROR_DEVICE_NOT_READY = (RASBASEERROR + 66)
Public Const ERROR_LINE_BUSY = (RASBASEERROR + 76)
Public Const ERROR_NO_ANSWER = (RASBASEERROR + 78)
Public Const ERROR_NO_CARRIER = (RASBASEERROR + 79)
Public Const ERROR_NO_DIALTONE = (RASBASEERROR + 80)
Public Const ERROR_AUTHENTICATION_FAILURE = (RASBASEERROR + 91)
Public Const ERROR_PPP_TIMEOUT = (RASBASEERROR + 118)
'**********************************
'* RAS连接状态声明 *
'**********************************
Enum RasConnState
    RASCS_OpenPort = 0
    RASCS_PortOpened             '1
    RASCS_ConnectDevice          '2
    RASCS_DeviceConnected        '3
    RASCS_AllDevicesConnected    '4
    RASCS_Authenticate           '5
    RASCS_AuthNotify             '6
    RASCS_AuthRetry
    RASCS_AuthCallback
    RASCS_AuthChangePassword
    RASCS_AuthProject
    RASCS_AuthLinkSpeed
    RASCS_AuthAck
    RASCS_ReAuthenticate
    RASCS_Authenticated
    RASCS_PrepareForCallback
    RASCS_WaitForModemReset
    RASCS_WaitForCallback
    RASCS_Projected
    RASCS_StartAuthentication  '19
    RASCS_CallbackComplete
    RASCS_LogonNetwork         '21
    RASCS_Interactive = &H1000
    RASCS_RetryAuthentication
    RASCS_CallbackSetByCaller
    RASCS_PasswordExpired
    RASCS_Connected = &H2000
    RASCS_Disconnected
End Enum
'**********************************
'* RAS API 声明 *
'**********************************
Public Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (lpString1 As Any, ByVal lpString2 As String) As Long
Public Declare Function RasDial Lib "rasapi32.dll" Alias "RasDialA" (lpRasDialExtensions As Any, ByVal lpszPhonebook As String, lprasdialparams As Any, ByVal dwNotifierType As Long, ByVal lpvNotifier As Long, lphRasConn As Long) As Long
Public Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" (lprasconn As Any, lpcb As Long, lpcConnections As Long) As Long
Public Declare Function RasEnumEntries Lib "rasapi32.dll" Alias "RasEnumEntriesA" (ByVal reserved As String, ByVal lpszPhonebook As String, lprasentryname As Any, lpcb As Long, lpcEntries As Long) As Long
Public Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long

'Sleep
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Function AddConnection(strNewEntryName As String, strNewPhoneNumber As String, strNewCallbackNumber As String, strNewUsername As String, strNewPassword As String, strNewDomain As String) As Integer

Dim lngRetCode As Long
Dim lngRetLstrcpy As Long
Dim lngRetHangUp As Long
Dim lprasdialparams As RASDIALPARAMS95

lprasdialparams.dwSize = 1052
lngRetLstrcpy = lstrcpy(lprasdialparams.szEntryName(0), strNewEntryName)
lngRetLstrcpy = lstrcpy(lprasdialparams.szPhoneNumber(0), strNewPhoneNumber)
lngRetLstrcpy = lstrcpy(lprasdialparams.szCallbackNumber(0), strNewCallbackNumber)
lngRetLstrcpy = lstrcpy(lprasdialparams.szUserName(0), strNewUsername)
lngRetLstrcpy = lstrcpy(lprasdialparams.szPassword(0), strNewPassword)
lngRetLstrcpy = lstrcpy(lprasdialparams.szDomain(0), strNewDomain)
hRasConn = 0 '
            lngRetCode = RasDial(ByVal APINULL, vbNullString, lprasdialparams, 0, AddressOf RasDialFunc, hRasConn) '异步通信
            'lngRetCode = RasDial(ByVal APINULL, vbNullString, lprasdialparams, APINULL, ByVal APINULL, hRasConn)

If lngRetCode Then
lngRetHangUp = RasHangUp(hRasConn)
End If
AddConnection = lngRetCode
End Function
Public Function GetConnections() As Integer
Dim lngRetCode As Long
Dim lpcb As Long
Dim lpcConnections As Long
Dim intArraySize As Integer

ReDim lprasconn95(intArraySize) As RASCONN95
lprasconn95(0).dwSize = 412
lpcb = 256 * lprasconn95(0).dwSize
lngRetCode = RasEnumConnections(lprasconn95(0), lpcb, lpcConnections)

' If lngRetCode = 0 Then
' End If
GetConnections = lpcConnections
End Function
Public Sub RemoveConnection()
    Dim s As Long, l As Long, ln As Long, a$, RasConn As Long, Ret As Long

    ReDim R(255) As RASCONN95

    R(0).dwSize = 412
    s = 256 * R(0).dwSize
    l = RasEnumConnections(R(0), s, ln)
    For l = 0 To ln - 1
        a$ = StrConv(R(l).szEntryName(), vbUnicode)
        a$ = left$(a$, InStr(a$, Chr$(0)) - 1)
        RasConn = R(l).hRasConn
        '这里将挂断连接
        Ret = RasHangUp(ByVal RasConn)
        Sleep (2000)
    Next
End Sub

Public Sub RasDialFunc(ByVal unMsg As Long, ByVal ConnState As Long, ByVal dwError As Long)
Dim strmsg As String
Select Case ConnState

    Case RASCS_OpenPort
        strmsg = "正在打开端口……"
    Case RASCS_PortOpened
        strmsg = "端口已打开。"
    Case RASCS_ConnectDevice
        strmsg = "正在连接设备"
    Case RASCS_DeviceConnected
        strmsg = "设备已连接。"
    'Case RASCS_AllDevicesConnected
    '    strmsg= "所有设备均已连接。"
    Case RASCS_Authenticate
        strmsg = "验证用户名及密码……"
    Case RASCS_AuthNotify
        strmsg = "RASCS_AuthNotify"
    Case RASCS_AuthRetry
        strmsg = "RASCS_AuthRetry"
    Case RASCS_AuthCallback
        strmsg = "RASCS_AuthCallback"
    Case RASCS_AuthChangePassword
        strmsg = "RASCS_AuthChangePassword"
    Case RASCS_AuthProject
        strmsg = "RASCS_AuthProject"
    Case RASCS_AuthLinkSpeed
        strmsg = "RASCS_AuthLinkSpeed"
    Case RASCS_AuthAck
        strmsg = "RASCS_AuthAck"
    Case RASCS_ReAuthenticate
        strmsg = "RASCS_ReAuthenticate"
    Case RASCS_Authenticated
        strmsg = "RASCS_Authenticated"
    Case RASCS_PrepareForCallback
        strmsg = "RASCS_PrepareForCallback"
    Case RASCS_WaitForModemReset
        strmsg = "RASCS_WaitForModemReset"
    Case RASCS_WaitForCallback
        strmsg = "RASCS_WaitForCallback"
    Case RASCS_Projected
        strmsg = "RASCS_Projected"
    Case RASCS_StartAuthentication
        strmsg = "RASCS_StartAuthentication"
    Case RASCS_CallbackComplete
        strmsg = "RASCS_CallbackComplete"
    Case RASCS_LogonNetwork
        strmsg = "RASCS_LogonNetwork"
    Case RASCS_Interactive
        strmsg = "RASCS_Interactive"
    Case RASCS_RetryAuthentication
        strmsg = "RASCS_RetryAuthentication"
    Case RASCS_CallbackSetByCaller
        strmsg = "RASCS_CallbackSetByCaller"
    Case RASCS_PasswordExpired
        strmsg = "RASCS_PasswordExpired"
    Case RASCS_Connected
        strmsg = "连接成功!"
    Case RASCS_Disconnected
        strmsg = "连接已断开!"
         
End Select
Select Case dwError
     
    Case ERROR_PORT_ALREADY_OPEN
        strmsg = "错误,端口已经打开!"
    Case ERROR_UNKNOWN
        strmsg = "未知的错误!"
    Case ERROR_REQUEST_TIMEOUT
        strmsg = "错误,请求超时!"
    Case ERROR_PASSWD_EXPIRED
        strmsg = "错误,您的密码错误!"
    Case ERROR_NO_DIALIN_PERMISSION
        strmsg = "错误,没有拨号音!"
    Case ERROR_SERVER_NOT_RESPONDING
        strmsg = "错误,拨入的远程计算机没有响应!"
    Case ERROR_UNRECOGNIZED_RESPONSE
        strmsg = "错误,未知的响应!"
    Case ERROR_NO_RESPONSES
        strmsg = "错误,没有响应!"
    Case ERROR_DEVICE_NOT_READY
        strmsg = "错误,设备没有准备好!"
    Case ERROR_LINE_BUSY
        strmsg = "错误,占线!"
    Case ERROR_NO_ANSWER
        strmsg = "错误,服务器无应答!"
    Case ERROR_NO_CARRIER
        strmsg = "错误,没有载波信号!"
    Case ERROR_NO_DIALTONE
        strmsg = "错误,没有拨号音!"
    Case ERROR_AUTHENTICATION_FAILURE
        strmsg = "用户名密码出错!"
    Case ERROR_PPP_TIMEOUT
        strmsg = "PPP接入超时。"
    Case 633
        strmsg = "错误,网络设备不存在或没打开电源!"
    Case 623
        strmsg = "错误,请建立新连接!"
    Case Else
        If dwError <> 0 Then strmsg = "拨号失败,重拨!"
        
End Select

Form1.List1.AddItem strmsg
Form1.List1.ListIndex = Form1.List1.NewIndex
End Sub


搜索更多相关主题的帖子: 状态栏 
2016-02-25 11:28
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
收藏
得分:0 
回复 2楼 wmf2014
怎么引用,我引用时生成EXE运行时出错
StatusBar1.Panels(1).Text=strmsg
2016-02-26 07:51
快速回复:高手指点把下面list显示拨号状态,改为状态栏显示应怎么改革者
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036183 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved