|
|
|
Here is the most advanced technique probably you have ever seen in VB. Haven't you been told by the "experts" that you can't do low level programming stuff in VB which you can do in C/C++/ASM ? But here I shall prove them wrong. This little code will demonstrate how to execute low level Machine instructions in VB to get CPU name. You can pass byte array containing low level machine instruction to CallWindowProc API. I will add more articles in VB & Assembly section in future.
Just copy and paste the following code into your form. |
Click here to copy the following block | 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
Public Function GetCpuName() As String
Dim MachineCode(0 To 35) As Byte Dim VarAddr As Long Dim EAX As Long Dim CPUName(1 To 12) As Byte
MachineCode(0) = &H55 MachineCode(1) = &H8B MachineCode(2) = &HEC MachineCode(3) = &H57 MachineCode(4) = &H52 MachineCode(5) = &H51 MachineCode(6) = &H53 MachineCode(7) = &H8B MachineCode(8) = &H45 MachineCode(9) = &H8 MachineCode(10) = &HF MachineCode(11) = &HA2 MachineCode(12) = &H8B MachineCode(13) = &H7D MachineCode(14) = &HC MachineCode(15) = &H89 MachineCode(16) = &H1F MachineCode(17) = &H8B MachineCode(18) = &H7D MachineCode(19) = &H10 MachineCode(20) = &H89 MachineCode(21) = &HF MachineCode(22) = &H8B MachineCode(23) = &H7D MachineCode(24) = &H14 MachineCode(25) = &H89 MachineCode(26) = &H17 MachineCode(27) = &H58 MachineCode(28) = &H59 MachineCode(29) = &H5A MachineCode(30) = &H55 MachineCode(31) = &HC9 MachineCode(32) = &HC2 MachineCode(33) = &H10 MachineCode(34) = &H0 EAX = 0
CallWindowProc VarPtr(MachineCode(0)), EAX, VarPtr(CPUName(1)), VarPtr(CPUName(9)), VarPtr(CPUName(5)) GetCpuName = StrConv(CPUName(), vbUnicode) End Function
Private Sub Form_Load() MsgBox GetCpuName End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|