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