当前位置: 网学 > 编程文档 > VB > 正文

VB中使用汇编一例

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式
H0
    
    ''tell cpuid what we want
    EAX = 0
    
    ''get address of Machine Code
    VarAddr = VarPtr(MachineCode(0))
    
    ''get address of Sub Dummy
    FunctAddr = GetAddress(AddressOf Dummy)
    
    ''copy the Machine Code to where it can be called
    CopyMemory ByVal FunctAddr, ByVal VarAddr, 35 ''35 bytes machine code
    
    ''call it
    On Error Resume Next ''apparently it gets a stack pointer error when in P-Code but i dont know why
      CallWindowProc FunctAddr, EAX, VarPtr(CPUName(1)), VarPtr(CPUName(9)), VarPtr(CPUName(5))
      ''Debug.Print Err; Err.Description
      ''MsgBox Err & Err.Description
    On Error GoTo 0
    
    GetCpuName = StrConv(CPUName(), vbUnicode) ''UnicodeName
    
End Function

Private Function GetAddress(Address As Long) As Long

    GetAddress = Address

End Function

Private Sub Dummy()

  ''the code below just reserves some space to copy the machine code into
  ''it is never executed

    x = 0
    x = 1
    x = 2
    x = 3
    x = 4
    x = 5
    x = 6
    x = 7
    x = 8
    x = 9
    x = 10
    x = 0
    x = 1
    x = 2
    x = 3
    x = 4
    x = 5
    x = 6
    x = 7
    x = 8
    x = 9
    x = 10
   
End Sub

  • 上一篇资讯: 如何用API定义程序热键
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号