关于 movememory 函数的问题 ,急急急....

cngufc 2003-05-27 02:27:00
我的程序是这样的:

Option Explicit
Private Declare Sub MoveMemory Lib "kernel32" Alias "Rtlmovememory" (destination
As Any, source As Any, source As Any, ByVal length As Long)

Private Sub Command1_Click()
On Error GoTo myerr
CommonDialog1.Filter = "bmp files(*.bmp)|*.bmp"
CommonDialog1.FileName = ""
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
Dim picfilename As String
If picfilename = "" Then Exit Sub
Dim picfilelen As Long
picfilelen = FileLen(picfilename)
Picture1.Picture = LoadPicture(picfilename)
Dim templen As Long
SavePicture Picture1.Picture, App.Path + "\temp.bmp"
templen = FileLen(App.Path + "\temp.bmp")
Kill App.Path + "temp.bmp"
If picfilelen > templen Then
MsgBox "该经过加密处理,不用再加密了! "
Exit Sub
End If
Dim txtfilename As String
CommonDialog1.Filter = "txtfile(*.txt)|*.txt"
CommonDialog1.CancelError = True
CommonDialog1.FileName = ""
CommonDialog1.ShowOpen
txtfilename = CommonDialog1.FileName
Dim txtfilelen As Long
txtfilelen = FileLen(txtfilename)
Dim mbyte() As Byte
ReDim mbyte(txtfilelen - 1)
Open txtfilename For Binary As 1
Get 1, , mbyte
Close 1
Dim nbyte() As Byte
ReDim nbyte(picfilelen - 1)
Open picfilename For Binary As 3
Get 3, , nbyte
Close 3
ReDim Preserve nbyte(picfilelen + txtfilelen - 1)
MoveMemory nbyte(picfilelen), mbyte(0), txtfilelen
Open picfilename For Binary As 2
Put 2, , nbyte
Close 2
Exit Sub
myerr:
Select Case Err.Number
Case 32755
MsgBox " 请选择一个文件"
Case 53
MsgBox "文件不存在或路径错误"
End Select
End Sub

Private Sub Command2_Click()
On Error GoTo myerr
CommonDialog1.Filter = "bmp files(*.bmp)|*.bmp"
CommonDialog1.FileName = ""
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
Dim picfilename As String
picfilename = CommonDialog1.FileName
If picfilename = "" Then Exit Sub
Dim picfilelen As Long
picfilelen = FileLen(picfilename)
Picture1.Picture = LoadPicture(picfilename)
Dim templen As Long
SavePicture Picture1.Picture, App.Path + "\temp.bmp"
templen = FileLen(App.Path + "\temp.bmp")
Kill App.Path + "\temp.bmp"
If picfilelen = templen Then
MsgBox "该文件还没有经过加密处理!"
Exit Sub
End If
Dim txtfilename As String
Dim txtfilelen As Long
CommonDialog1.Filter = "txt files(*.txt|*.txt)"
CommonDialog1.CancelError = True
CommonDialog1.FileName = ""
CommonDialog1.ShowSave
txtfilename = CommonDialog1.FileName
Dim txtfilelenas As Long
txtfilelen = picfilelen - templen
Dim mbyte() As Byte
ReDim mbyte(txtfilelen - 1)
Dim nbyte() As Byte
ReDim nbyte(picfilelen - 1)
Open picfilename For Binary As 3
Get 3, , nbyte
Close 3

MoveMemory mbyte(0), nbyte(templen + 1), txtfilelen
Open txtfilename For Binary As 2
Put 2, , mbyte
Close 2
Exit Sub
myerr:
Select Case Err.Number
Case 32755
MsgBox "请选择一个文件"
Case 53
MsgBox "文件不存在或路径错误"
End Select
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Form_Load()
Picture1.Visible = False

End Sub

调试时说编译错误,参数不可选 光标停在movememory处,代码是打进去的,api 浏览器中找
不到movememory


挺急的 还请多多帮忙:)

===================================================================

...全文
269 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
koa3000 2003-05-27
  • 打赏
  • 举报
回复

Private Declare Sub MoveMemory Lib "kernel32" Alias "Rtlmovememory" (destination
As Any, source As Any, source As Any, ByVal length As Long)

这个声明有误,多了一个source As Any,应该如下

Private Declare Sub MoveMemory Lib "kernel32" Alias "Rtlmovememory" (destination As Any, source As Any, ByVal length As Long)
rainstormmaster 2003-05-27
  • 打赏
  • 举报
回复
代码看起来很熟呀,测试一下txtfilelen和templen + 1的值,看看是否有效。在api浏览器中找不到MoveMemory的,MoveMemory其实就是copyMemory。
chao778899 2003-05-27
  • 打赏
  • 举报
回复
Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal ByteLen As Long)

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧