| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3836 人关注过本帖
标题:拨号连接提示"尝试读取或写入受保护的内存。这通常指示其他内存已损坏。" ...
只看楼主 加入收藏
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
结帖率:47.37%
收藏
 问题点数:0 回复次数:1 
拨号连接提示"尝试读取或写入受保护的内存。这通常指示其他内存已损坏。"
尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

代码如下:Imports System.Runtime.InteropServices

Module link
    Public hRasConn As Integer '定义一个指向RAS调用的全局句柄
    Public Const APINULL = 0&
    Public Const UNLEN = 256
    Public Const DNLEN = 15
    Public Const PWLEN = 256
    Public Structure RASCONN95

        Public dwSize As Integer
        Public hRasConn As Integer
        Public szEntryName As String
        Public szDeviceType As String
        Public szDeviceName As String
    End Structure

    Public Structure RASCONNSTATUS95
        Public dwSize As Integer
        Public RasConnState As Integer
        Public dwError As Integer
        Public szDeviceType As String
        Public szDeviceName As String
    End Structure

    Public Structure RASDIALPARAMS95
        Public dwSize As Integer
        Public szEntryName As String
        Public szPhoneNumber As String
        Public szCallbackNumber As String
        Public szUserName As String
        Public szPassword As String
        Public szDomain As String
    End Structure

    Public Declare Auto Function RasDial Lib "RasApi32.DLL" Alias "RasDialA" (ByVal lpRasDialExtensions As Integer, ByVal lpszPhonebook As String, ByVal lprasdialparams As RASDIALPARAMS95, ByVal dwNotifierType As Integer, ByVal lpvNotifier As Integer, ByRef lphRasConn As Integer) As Integer
    Public Declare Auto Function RasHangUp Lib "RasApi32.DLL" Alias "RasHangUpA" (ByVal hRasConn As Integer) As Integer

    Public Function AddConnection(ByVal strNewEntryName As String, ByVal strNewPhoneNumber As String, ByVal strNewCallbackNumber As String, ByVal strNewUsername As String, ByVal strNewPassword As String, ByVal strNewDomain As String) As Integer
        Dim lprasdialparams As RASDIALPARAMS95
        Dim lngRetCode As Integer
        Dim lngRetHangUp As Integer
        lprasdialparams.dwSize = Marshal.SizeOf(GetType(RASDIALPARAMS95))
        lprasdialparams.szEntryName = strNewEntryName
        lprasdialparams.szPhoneNumber = strNewPhoneNumber
        lprasdialparams.szCallbackNumber = strNewCallbackNumber
        lprasdialparams.szUserName = strNewUsername
        lprasdialparams.szPassword = strNewPassword
        lprasdialparams.szDomain = strNewDomain

        lngRetCode = RasDial(APINULL, vbNullString, lprasdialparams, APINULL, APINULL, hRasConn)

        If lngRetCode > 0 Then
            lngRetHangUp = RasHangUp(hRasConn)
        End If
        AddConnection = lngRetCode
    End Function
End Module
2016-05-23 09:57
ufopsdc
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-11-10
收藏
得分:0 
这情况多是发生在取值范围超过,源数据的大小
2016-06-14 16:15
快速回复:拨号连接提示"尝试读取或写入受保护的内存。这通常指示其他内存已损坏 ...
数据加载中...
 
   



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

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