以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]尝试读取或写入受保护的内存  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=60493)

--  作者:mojo
--  发布时间:2014/11/25 20:42:00
--  [求助]尝试读取或写入受保护的内存
xp开发版设计项目发布正常使用,但是发布文件在win7系统上出现尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
图片点击可在新窗口打开查看此主题相关图片如下:无标题.png
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2014/11/25 20:43:00
--  

 右键,设置用管理员身份运行;

 

 贴出你写了什么代码。


--  作者:mojo
--  发布时间:2014/11/25 20:48:00
--  
不好意思代码有点乱,初步设计阶段:
Dim lb11 As WinForm.Label = e.Form.Controls("Label11")
Dim lb12 As WinForm.Label = e.Form.Controls("Label12")
Dim lb13 As WinForm.Label = e.Form.Controls("Label13")
Dim lb14 As WinForm.Label = e.Form.Controls("Label14")
Dim lb15 As WinForm.Label = e.Form.Controls("Label15")
Dim lb16 As WinForm.Label = e.Form.Controls("Label16")
Dim lb17 As WinForm.Label = e.Form.Controls("Label17")
Dim lb19 As WinForm.Label = e.Form.Controls("Label19")
Dim Pc1 As WinForm.PictureBox = e.Form.Controls("PictureBox1")
Dim tb5 As WinForm.TextBox = e.Form.Controls("TextBox5")


lb11.text =""
lb12.text =""
lb13.text =""
lb14.text =""
lb15.text =""
lb16.text =""
lb17.text =""
lb19.text =""
tb5.text = ""
Pc1.image = GetImage("")

e.Form.Controls("Button2").Enabled = False
e.Form.Controls("Button3").Enabled = False

Dim result As Integer
Dim CardID (0 To 4) As Byte


If Vars("IcDev")<= 0 Then
    MessageBox.Show("未连接读写设备!", "提示")
    Exit Sub
End If

\'result= dc_card_chr (Vars("IcDev"), 0, CardID(0))
\'If result < 0 Then
\'  MessageBox.Show("请放入卡片!" + Cstr(result), "提示")
\'  Exit Sub
\'End If


result=DC_find_i_d(Vars("IcDev"))

If result < 0 Then
    MessageBox.Show("请检查身份证是否放入!", "提示")
    Exit Sub
End If

\'MessageBox.Show("读取身份证信息!", "提示")

Vars("IcID")= DC_start_i_d(Vars("IcDev"))
If Vars("IcID") <0 Then
    MessageBox.Show("读取身份证信息失败!", "提示")
    Exit Sub
End If

\'MessageBox.Show("读取身份证1!", "提示")
lb11.text =DC_i_d_query_name(Vars("IcID"))

\'MessageBox.Show("读取身份证2!", "提示")
lb12.text  =DC_i_d_query_sex(Vars("IcID"))

\'MessageBox.Show("读取身份证3!", "提示")
lb13.text =DC_i_d_query_nation(Vars("IcID"))

\'MessageBox.Show("读取身份证4!", "提示")
lb14.text =DC_i_d_query_birth(Vars("IcID"))


\'MessageBox.Show("读取身份证5!", "提示")
lb15.text =DC_i_d_query_id_number(Vars("IcID"))


\'MessageBox.Show("读取身份证6!", "提示")
lb16.text =DC_i_d_query_address(Vars("IcID"))


\'MessageBox.Show("读取身份证7!", "提示")
lb17.text =DC_i_d_query_expire_day(Vars("IcID"))


\'MessageBox.Show("读取身份证8!", "提示")
lb19.text =DC_i_d_query_department(Vars("IcID"))


Dim FileName(16) As Byte
FileName = System.Text.Encoding.Default.GetBytes("~me.bmp")

\'MessageBox.Show("读取身份证9!", "提示")
result = DC_i_d_query_photo_file(Vars("IcID"),FileName )   \'相片
If result >= 0 Then
    Pc1.Image = GetImage("~me.bmp")
Else
    MessageBox.Show("读取身份证照片失败!", "提示")
    Exit Sub
End If   

\'MessageBox.Show("读取身份证照片成功!", "提示")

result=DC_end_i_d(Vars("IcID"))

If result <0 Then
    MessageBox.Show("读取身份证信息失败!", "提示")
    Exit Sub
End If

\'进行人员表操作
Dim Position1 As Integer
\'Position1 = Tables("人员清单").Find("身份证号码 = \'" & lb15.text & " \' ") \'查找是否存在
Position1 = Tables("人员清单").Find( lb15.text, 0, "身份证号码", False, True, True ) \'查找是否存在
If Position1>=0 Then  \'如果此用户存在
    e.Form.Controls("Button2").Enabled = True
    e.Form.Controls("Button3").Enabled = True
    Tables("人员清单").position = position1
    \'e.Form.Controls("Groupbox1").visible = True
    
    Dim Position2 As Integer
    Position2 = Tables("职工信息").Find(Tables("人员清单").current("身份证号码"), 0, "身份证号码", False, True, True ) \'查找是否存在
    If Position2 >=0 Then
        Tables("职工信息").position = position2
        tb5.text = "有此人员,所属公司:"+Tables("职工信息").current("所属公司")
    Else
        tb5.text = "职工信息表无此用户"
    End If
    
    
Else  \'如果数据表没有此用户
    e.Form.Controls("Button2").Enabled = False
    e.Form.Controls("Button3").Enabled = True
    \'e.Form.Controls("Groupbox1").visible = False
    
    Dim Position2 As Integer
    Position2 = Tables("职工信息").Find(lb15.text, 0, "身份证号码", False, True, True ) \'查找是否存在
    If Position2 >=0 Then
        Tables("职工信息").position = position2
        tb5.text = "有此人员,所属公司:"+Tables("职工信息").current("所属公司")
    Else
        tb5.text = "职工信息表无此用户"
    End If
    
End If

MessageBox.Show("读取身份证信息成功!", "提示")

--  作者:有点甜
--  发布时间:2014/11/25 20:53:00
--  

1、你要用管理员身份运行

 

2、报这个错,通常是函数定义有问题,贴出你 全局代码


--  作者:mojo
--  发布时间:2014/11/25 20:57:00
--  
全局代码
Public Declare Function dc_init Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll" (ByVal Port As Integer, ByVal Baud As Integer) As Integer \'连接设备
Public Declare Function dc_init_comm Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll" ( DeviceName As String,  Baudrate As Integer ) As Integer
Public Declare Function dc_beep Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll" ( icdev As Integer, ms As Integer) As Integer
Public Declare Function dc_exit Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  ( icdev As Integer) As Integer
Public Declare Function DC_find_i_d Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  ( DeviceHandle As Integer) As Integer
Public Declare Function DC_start_i_d Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  ( DeviceHandle As Integer) As Integer
Public Declare Function DC_end_i_d Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  ( IdHandle  As Integer) As Integer
Public Declare Function DC_i_d_query_name Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  ( IdHandle  As Integer) As String
Public Declare Function DC_i_d_query_sex Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  ( IdHandle  As Integer) As String
Public Declare Function DC_i_d_query_nation Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  ( IdHandle  As Integer) As String
Public Declare Function DC_i_d_query_birth Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal IdHandle As Long) As String
Public Declare Function DC_i_d_query_address Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal IdHandle As Long) As String
Public Declare Function DC_i_d_query_id_number Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal IdHandle As Long) As String
Public Declare Function DC_i_d_query_department Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal IdHandle As Long) As String
Public Declare Function DC_i_d_query_expire_day Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal IdHandle As Long) As String
Public Declare Function a_hex Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal asc$, ByRef hex As Byte, ByVal len1 As Integer) As Integer
Public Declare Function hex_a Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByRef sdata As Byte, ByVal gdata$, ByVal len1 As Integer) As Integer
Public Declare Function DC_i_d_query_photo_file Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal IdHandle As Integer, ByVal FileName As Byte()) As Integer
\'Public Declare Function DC_i_d_query_photo_file Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal IdHandle As Integer, Byref FileName As Stringbuilder) As Integer


\'for M1 card
Public Declare Function dc_card Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal mode%, ByRef Snr As Long) As Integer
Public Declare Function dc_load_key Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal mode%, ByVal secnr%, ByVal nkey As Byte()) As Integer
Public Declare Function dc_load_key_hex Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal mode%, ByVal secnr%, ByVal nkey As Byte()) As Integer
Public Declare Function dc_authentication Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal mode%, ByVal scenr%) As Integer
Public Declare Function dc_authentication_pass Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal mode%, ByVal scenr%, ByVal nkey As Stringbuilder) As Integer
Public Declare Function dc_read Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal adr%, ByVal sdata As Byte()) As Integer
Public Declare Function dc_read_hex Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal adr%, ByVal sdata As Byte()) As Integer
Public Declare Function dc_write Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal adr%, ByVal sdata As Byte()) As Integer
Public Declare Function dc_write_hex Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer, ByVal adr%, ByVal sdata As Byte()) As Integer
Public Declare Function dc_halt Lib "C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器\\Trf32.dll"  (ByVal icdev As Integer) As Integer



--  作者:有点甜
--  发布时间:2014/11/25 21:02:00
--  
 那不发布的,在win7中使用是否正常?用管理员身份运行
--  作者:mojo
--  发布时间:2014/11/25 21:05:00
--  
也是一样问题
--  作者:有点甜
--  发布时间:2014/11/25 21:15:00
--  

win7里,用管理员身份运行exe了吗?

 

再者,在对应路径下,注册了dll了吗?C:\\Program Files\\深圳市德卡科技有限公司\\T10N多功能读写器