| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2852 人关注过本帖
标题:下面拨号,我想状态栏改为拨号过程显示,怎么改
只看楼主 加入收藏
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
结帖率:47.37%
收藏
 问题点数:0 回复次数:6 
下面拨号,我想状态栏改为拨号过程显示,怎么改
    temp = AddConnection(sEntryName, "", "", sUsername, sPassword, "")
   Select Case temp
    Case -1
        StatusBar1.Panels(1).Text = "已连接,不能再连接一次,如需连接请先挂断。"
    Case 605
        StatusBar1.Panels(1).Text = "无法设置端口信息。"
    Case 606
        StatusBar1.Panels(1).Text = "无法连接端口。"
    Case 617
        StatusBar1.Panels(1).Text = "端口或设备已断开连接。"
    Case 618
        StatusBar1.Panels(1).Text = "端口尚未打开。"
    Case 619, 628
        StatusBar1.Panels(1).Text = "端口已断开连接。"
    Case 621, 622, 623, 624, 625
        StatusBar1.Panels(1).Text = "不存在的连接!"
    Case 629
       StatusBar1.Panels(1).Text = "端口已由远程机器断开连接。"
    Case 633, 651, 734
       StatusBar1.Panels(1).Text = "调制解调器(其他设备)已在使用。"
    Case 634
        StatusBar1.Panels(1).Text = "无法在远程网络上注册您的计算机。"
    Case 642
        StatusBar1.Panels(1).Text = "您的一个 NetBIOS 名称已在远程网络上注册。"
    Case 646
        StatusBar1.Panels(1).Text = "不允许本帐户在此时间登录。"
    Case 647
        StatusBar1.Panels(1).Text = "帐户已禁用。"
    Case 648
        StatusBar1.Panels(1).Text = "该帐户的密码已过期。"
    Case 649
        StatusBar1.Panels(1).Text = "帐户没有远程访问权限。"
    Case 676
        StatusBar1.Panels(1).Text = "线路忙。"
    Case 678, 809
        StatusBar1.Panels(1).Text = "远程计算机没有响应或者连接被远程计算机终止。"
    Case 691
        StatusBar1.Panels(1).Text = "由于域上的用户名和/或密码无效而拒绝访问或电信VPDN到期,请续费!"
    Case 708
        StatusBar1.Panels(1).Text = "帐户已过期。"
    Case 709
        StatusBar1.Panels(1).Text = "在域上更改密码时出错。"
    Case 734
        StatusBar1.Panels(1).Text = "PPP协议控制终止。"
    Case 741
        StatusBar1.Panels(1).Text = "核对属性设置是否正确。"
    Case 720
        StatusBar1.Panels(1).Text = "不能建立到远程计算机的连接。您可能需要更改些连接的网络设置。"
    Case 768
        StatusBar1.Panels(1).Text = "因为错误的加密数据造成连接请求失败。"
    Case 769
        StatusBar1.Panels(1).Text = "服务器IP出错。"
    Case 770
        StatusBar1.Panels(1).Text = "远程设备拒绝连接请求。"
    Case 771
        StatusBar1.Panels(1).Text = "因为网络忙造成连接请求失败。"
    Case 756
        StatusBar1.Panels(1).Text = "拔号连接正在进行。"
    Case 774
        StatusBar1.Panels(1).Text = "因为临时性错误导致连接请求失败。请再试着连接。"
    Case 775
        StatusBar1.Panels(1).Text = "连接被远程服务器阻止。"
    Case 781, 789
        StatusBar1.Panels(1).Text = "L2TP连接尝试失败,请运行基本设置下的注册表修改,然后重启电脑!"
    Case 0
        StatusBar1.Panels(1).Text = "连接成功"
    Case Else
        StatusBar1.Panels(1).Text = "没有更详细的错误信息!"
    End Select
搜索更多相关主题的帖子: 状态栏 信息 
2016-02-22 14:58
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
收藏
得分:0 
回复 楼主 rogersgb
比如,显示下面这种提示Public Sub RasDialFunc(ByVal unMsg As Long, _
ByVal ConnState As Long, _
ByVal dwError As Long)
Dim strMsg As String
Select Case ConnState
Case 0
strMsg = "正在打开..."
Case 1
strMsg = "端口已经打开!"
Case 2
strMsg = "正在连接设备..."
Case 3
strMsg = "设备已经连接"
Case 4
strMsg = "所有设备已经连接"
Case 5
strMsg = "正在验证用户名及口令..."
Case 6
strMsg = "验证通告..."
Case 7
strMsg = "验证重试..."
Case 8
strMsg = "验证回叫..."
Case 9
strMsg = "验证回叫..."
Case 10
strMsg = "验证项目..."
Case 11
strMsg = "验证连接速度..."
Case 12
strMsg = "验证请求..."
Case 13
strMsg = "重新验证..."
Case 14
strMsg = "验证完成!"
Case 15
strMsg = "准备回叫..."
Case 16
strMsg = "等待调制解调器复位"
Case 17
strMsg = "等待回叫..."
Case 18
strMsg = "projected"
Case 19
strMsg = "开始鉴定..."
Case 20
strMsg = "回叫完成!"
Case 21
strMsg = "正在登录网络..."
Case 4096
strMsg = "连接已经成功!"
Case 4097
strMsg = "重新鉴定..."
Case 4098
strMsg = "设置回叫..."
Case 4099
strMsg = "口令错误!"
Case 8192
strMsg = "已经连接啦!"
Case 8193
strMsg = "已经断开啦!"
End Select
2016-02-22 15:00
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
收藏
得分:0 
回复 2楼 rogersgb
有没有人会,请高手出手
2016-02-22 15:02
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
首先,改成 函数定义,如
Public Function RasDialFunc(ByVal unMsg As Long, ByVal ConnState As Long, ByVal dwError As Long) As String

其次,最后增加一句,如:
RasDialFunc = strMsg

调用:记得按实际情况写参数进去,这里是使用直接数举例。
如显示在状态栏:
StatusBar1.Panels(1).Text = RasDialFunc(0,1,0)

显示在文本框:
text1.text = RasDialFunc(0,1,0)

不知看明白了吗?

授人于鱼,不如授人于渔
早已停用QQ了
2016-02-22 15:08
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
还有一种不修改调用。但把代码直接改为非通用。

按你开头的定义,最后增加一句显示。如显示到文本框中:

......
  end select
  text1.text = strMsg
end sub



授人于鱼,不如授人于渔
早已停用QQ了
2016-02-22 15:12
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
收藏
得分:0 
回复 4楼 风吹过b
有点不明白,我的意思是在状态栏上显示拨号过程连接信息和错误代码,拨号方式是用    temp = AddConnection(sEntryName, "", "", sUsername, sPassword, "")
拨号过程中返回值如显示下面内容的状态,最好例程一个给我,我是新手,有点不懂
Select Case ConnState
Case 0
strMsg = "正在打开..."
Case 1
strMsg = "端口已经打开!"
Case 2
strMsg = "正在连接设备..."
Case 3
strMsg = "设备已经连接"
Case 4
strMsg = "所有设备已经连接"
Case 5
strMsg = "正在验证用户名及口令..."
Case 6
strMsg = "验证通告..."
Case 7
strMsg = "验证重试..."
Case 8
strMsg = "验证回叫..."
Case 9
strMsg = "验证回叫..."
Case 10
strMsg = "验证项目..."
Case 11
strMsg = "验证连接速度..."
Case 12
strMsg = "验证请求..."
Case 13
strMsg = "重新验证..."
Case 14
strMsg = "验证完成!"
Case 15
strMsg = "准备回叫..."
Case 16
strMsg = "等待调制解调器复位"
Case 17
strMsg = "等待回叫..."
Case 18
strMsg = "projected"
Case 19
strMsg = "开始鉴定..."
Case 20
strMsg = "回叫完成!"
Case 21
strMsg = "正在登录网络..."
Case 4096
strMsg = "连接已经成功!"
Case 4097
strMsg = "重新鉴定..."
Case 4098
strMsg = "设置回叫..."
Case 4099
strMsg = "口令错误!"
Case 8192
strMsg = "已经连接啦!"
Case 8193
strMsg = "已经断开啦!"
End Select
2016-02-22 17:05
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
收藏
得分:0 
回复 4楼 风吹过b
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

If GetConnections() > 0 Then
AddConnection = lngRetCode: Exit Function
End If
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)

Screen.MousePointer = vbHourglass
hRasConn = 0 '
lngRetCode = RasDial(ByVal APINULL, vbNullString, lprasdialparams, APINULL, ByVal APINULL, hRasConn)
'lngRetCode = RasDial(ByVal APINULL, vbNullString, lprasdialparams, 0, AddressOf RasDialFunc, hRasConn) '异步通信
Screen.MousePointer = vbDefault
'
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 Function 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
RasDialFunc = strmsg
End Function


窗体FORM中如何调用拨号过程信息,请指教
2016-02-24 18:00
快速回复:下面拨号,我想状态栏改为拨号过程显示,怎么改
数据加载中...
 
   



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

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