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

VB中使用汇编一例

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式
bsp;       =   75
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)

    Label1 = ""
    Label2 = ""

End Sub

Private Sub Command1_Click()
    
    Label1 = GetCpuName() & " CPU"
    Label2 = "You have a" & IIf(InStr("AEIOU", Left$(Label1, 1)), "n", "")

End Sub
------------------------------end---------------------------------





下面是modu1e.bas的源代码

----------------------module1.bas的源文件--------------------------
Option Explicit
''
''This shows how to incorporate machine code into VB
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''The example fills the array with a few machine instructions and then copies
''them to a procedure address. The modified procedure is then called thru
''CallWindowProc. The result of this specific machine code is your CPU Vendor Name.
''
''##########################################################################
''Apparently it gets a Stack Pointer Error, but I don''t know why; if anybody
''can fix that please let me know                          UMGEDV@AOL.COM
''The Error is not present in the native compiled version; so I think it got
''something to do with the P-Code Calling Convention (strange though)
''##########################################################################
''
''Sub Dummy serves to reserve some space to copy the machine instructions into.
''
''
''Tested on Intel and AMD CPU''s (uncompiled and compiled)
''
''
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Private x As Long

Public Function GetCpuName() As String
  
  Dim MachineCode(0 To 35)  As Byte
  Dim VarAddr               As Long
  Dim FunctAddr             As Long
  Dim EAX                   As Long
  Dim CPUName(1 To 12)      As Byte
  
  ''set up machine code
  &nb
  • 上一篇资讯: 如何用API定义程序热键
  • 网学推荐

    免费论文

    原创论文

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