VB没怎么用过,不过VB中好像不能直接调用CPUID指令(0A20F)!至于获得网卡MAC,用搜索引擎一找一大堆~~~http://jinjohn.myrice.com/program/vb/network/bnet0014.htm
http://bbs.sjtu.edu.cn/cgi-bin/bbscon?board=VB&file=M.951117911.A&num=96
http://support.microsoft.com/support/kb/articles/Q118/6/23.asp
http://www.applevb.com/art/ar_wmi.htm
http://bbs.uestc.edu.cn/cgi-bin/bbs2www/bbscon?board=DotNet&file=M.1028107008.A&num=724&title=334
http://bbs.sjtu.edu.cn/cgi-bin/bbscon?board=VB&file=M.951117911.A&num=96
http://support.microsoft.com/support/kb/articles/Q118/6/23.asp
http://www.applevb.com/art/ar_wmi.htm
http://bbs.uestc.edu.cn/cgi-bin/bbs2www/bbscon?board=DotNet&file=M.1028107008.A&num=724&title=334
asm
pushad
mov eax, 0
db 0fh, 0a2h // 其实就是cpuid汇编指令
mov dword ptr R[0], ebx
mov dword ptr R[4], edx
mov dword ptr R[8], ecx
mov eax, 1
db 0fh, 0a2h // cpuid
mov CpuID, edx
popad
end;
再补充点:CPUID指令
1. CPUID指令代码: 0a20f
例:
CPUID MACRO
dw 0a20fh
ENDM
2. CPUID有效检测
如果程序可以改变EFLAGE(扩展标志字)的第21位,那么CPUID有效,
否则无效。
注:对于Cyrix的CPU,在打开其内部CPUID标志位之前,用此方法检测
无效。
例:
...
pushfd
pop eax
mov ecx,eax
xor eax,200000h ;强制扩展标志位第21位为1
push eax
popfd
pushfd
pop eax
xor eax,ecx ;如果扩展标志位的第21位为1,那么
je no_cpuid ;CPUID存在,否则不存在
jmp have_cpuid
...
3. CPUID指令
(1)基本指令
1.第0号功能: (EAX=0)
调用寄存器:
EAX=0
返回寄存器:
EAX=最大功能号
EBX:EDX:ECX=CPU厂商识别串
例:
...
xor eax,eax
CPUID
cmp ebx,"Genu"
jne no_intel
cmp edx,"ineI"
jne no_intel
cmp ecx,"ntel"
jne no_intel
jmp is_intel
...
合并ebx,edc,ecx寄存器的值,如果为GenuineIntel,就是Intel的CPU 另:
AuthenticAMD => AMD
CyrixInstead => Cyrix,被VIA兼并了
NexGenDriven => NextGen
RiseRiseRise => Rise
UMC UMC UMC => UMC
CentaurHauls => IDT 2.第1号功能: (EAX=1)
调用寄存器
EAX=1
返回寄存器
EAX=CPU说明
CPU说明(见附录1)
bit 内容
0--3 节率 (stepping)
4--7 型号 (model)
8--11 家族 (family)
EDX=特征标志字
bit 内容 缩写
0 FPU On-chip FPU
1 Virtual Mode Extension VME
2 Debugging Extension DE
3 Page Size Extension PSE
4 Time Stamp Counter TSC
5 RDMSR/WRMSR Instructions
6 Physical Address Extension PAE
7 Machine Check Exception MCE
8 CMPXCHG8B Instruction
9 On-chip APIC HardWare
10 Undefined
11 SYSENTER/SYSEXIT Instructions
12 Memory Type Range Registers
13 Page Global Enable PGE
14 Machine Check Architecture MCA
15 Conditional Move Instruction CMI
16 Page Attribute Table PAT
17--22 Undefined
23 MMX Instructions MMX
24 internet Streaming SIMD Extensions SSE
25--31 Undefined
(2)扩展指令
1.第80000000号功能(EAX=80000000h)
调用寄存器:
EAX=80000000h
返回寄存器:
EBX,ECX,EDX=保留
EAX=最大功能号 2.第80000001号功能
调用寄存器:
EAX=80000001h
返回寄存器:
EAX=CPU说明(见第1号功能)
EDX=扩展特征标志字
EDX[0] <- FPU: FPU on Chip
EDX[1] <- VME: Virtual Mode Extention present
EDX[2] <- DE: Debbuging Extentions
EDX[3] <- PSE: CPU support 4MB size pages
EDX[4] <- TSC: TSC present (See RDTSC command)
EDX[5] <- MSR: CPU have K5 Compatible MSRs
EDX[6] <- 0 (Reserved)
EDX[7] <- MCE: Machine Check exception
EDX[8] <- CX8: Support CMPXCHG8B instruction
EDX[9] <- Reserved
EDX[10]<- Support SYSCALL and SYSRET instruction (!!!)
EDX[11,12]<- reserved
EDX[13]<- PGE: Page Global Feature support
EDX[14]<- reserved
EDX[15]<- CMOV: CPU support CMOV instruction
EDX[16]<- FCMOV: CPU support FP. FCMOV (!!!)
EDX[22..16] <- Reserved
EDX[23] <- MMX: CPU support IA MMX
EDX[24] <- (Cyrix) Cyrix Extended MMX
EDX[30..24] <- Reserved
EDX[31] <- AMD 3DNow!
1. Cyrix
厂商识别串: "CyrixInstead"
CPU名称 家族 型号
MediaGX 4 4
6x86 5 2 (特征标志字=0x1)
6x86L 5 2 (特征标志字=0x105)
GXm 5 4
6x86MX 6 0
2. NexGen
厂商识别串: "NexGenDriven"
CPU名称 家族 型号
Nx586 5 3. UMC
厂商识别串: "UMC UMC UMC "
CPU名称 家族 型号
U5D 4 1
U5S 4 24. AMD
厂商识别串: "AuthenticAMD"
CPU名称 家族 型号
486DX2WT 4 3
486DX2WB 4 7
486DX4WT 4 8
486DX4WB 4 9
5x86WT 4 0x0e
5x86WB 4 0x0f
486 4 Others
K5/SS 5 0
K5 5 1,2,3
K6 5 6,7
K6-2 5 8
K6-III 5 9
K5/K6 5 Others
K7工程样本 6 0
K7 6 Others5. IDT
厂商识别串: "CentaurHauls"
CPU名称 家族 型号
WinChip C6 5 4
WinChip 2 5 86 Rise
厂商识别串: "RiseRiseRise"
CPU名称 家族 型号
mP6 5 07. Intel
厂商识别串: "GenuineIntel"
CPU名称 家族 型号
PentiumII 6 3
Celeron 6 5
CeleronA 6 6
PentiumIII 6 7
PentiumPro OverDrive P6 6 1
PentiumPro 6 Others
PentiumP5 5 1
PentiumP54C 5 2
Pentiumi486 5 3
PentiumMMX 5 4
PentiumDX4 5 5
Pentium OverDrive P5 5 6
Pentium 5 Others
486DX 4 0,1
486SX 4 2
486DX2 4 3
486SL 4 4
486SX2 4 5
486DX2_WB 4 7
486DX4 4 8
Celeron 7,8 1
Pentium III Xeon 7,8 3
Pentium IV 7,8 4
Pentium III 7,8 L2Cache<1024
Pentium III Xeon 7,8 other
Pentium III Xeon 10($A)
Pentium VI or Ithanium 15($F)用其它开发工具做个动态链接库文件供VB调用!
谢谢了
private const ncbastat = &h33
private const ncbnamsz = 16
private const heap_zero_memory = &h8
private const heap_generate_exceptions = &h4
private const ncbreset = &h32
private type ncb
ncb_command as byte
ncb_retcode as byte
ncb_lsn as byte
ncb_num as byte
ncb_buffer as long
ncb_length as integer
ncb_callname as string * ncbnamsz
ncb_name as string * ncbnamsz
ncb_rto as byte
ncb_sto as byte
ncb_post as long
ncb_lana_num as byte
ncb_cmd_cplt as byte
ncb_reserve(9) as byte ' reserved, must be 0
ncb_event as long
end type
private type adapter_status
adapter_address(5) as byte
rev_major as byte
reserved0 as byte
adapter_type as byte
rev_minor as byte
duration as integer
frmr_recv as integer
frmr_xmit as integer
iframe_recv_err as integer
xmit_aborts as integer
xmit_success as long
recv_success as long
iframe_xmit_err as integer
recv_buff_unavail as integer
t1_timeouts as integer
ti_timeouts as integer
reserved1 as long
free_ncbs as integer
max_cfg_ncbs as integer
max_ncbs as integer
xmit_buf_unavail as integer
max_dgram_size as integer
pending_sess as integer
max_cfg_sess as integer
max_sess as integer
max_sess_pkt_size as integer
name_count as integer
end type
private type name_buffer
name as string * ncbnamsz
name_num as integer
name_flags as integer
end type
private type astat
adapt as adapter_status
namebuff(30) as name_buffer
end type
private declare function netbios lib "netapi32.dll" _
(pncb as ncb) as byte
private declare sub copymemory lib "kernel32" alias _
"rtlmovememory" (hpvdest as any, byval hpvsource as long, _
byval cbcopy as long)
private declare function getprocessheap lib "kernel32" () _
as long
private declare function heapalloc lib "kernel32" _
(byval hheap as long, byval dwflags as long, _
byval dwbytes as long) as long
private declare function heapfree lib "kernel32" _
(byval hheap as long, byval dwflags as long, lpmem as any) _
as long
private function ethernetaddress(lananumber as long) _
as string
dim udtncb as ncb
dim bytresponse as byte
dim udtastat as astat
dim udttempastat as astat
dim lngastat as long
dim strout as string
dim x as integer
udtncb.ncb_command = ncbreset
bytresponse = netbios(udtncb)
udtncb.ncb_command = ncbastat
udtncb.ncb_lana_num = lananumber
udtncb.ncb_callname = "* "
udtncb.ncb_length = len(udtastat)
lngastat = heapalloc(getprocessheap(), _
heap_generate_exceptions or heap_zero_memory, udtncb.ncb_length)
strout = ""
if lngastat then
udtncb.ncb_buffer = lngastat
bytresponse = netbios(udtncb)
copymemory udtastat, udtncb.ncb_buffer, len(udtastat)
with udtastat.adapt
for x = 0 to 5
strout = strout & right$("00" & hex$(.adapter_address(x)), 2)
next x
end with
heapfree getprocessheap(), 0, lngastat
end if
ethernetaddress = strout
end function
我知道你想干嘛,想使用它来对你做出的程序进行序列号保护对吧,用硬盘的序列号吧:)。要说明的是少数硬盘没有序列号哦:)。但是90%以上的硬盘是有的,而且唯一(厂家出厂时已设定,而且只读)。此外硬盘分区的格式化序列号也是一种不错的选择,只是每格式化一次它就会变。
本来想把这两个东东的源程序给你的,不过,看你也不象大方的样子,再说了,你要的也不是这东西,就算啦:)。
竟然如此,就算了吧!结贴!!!
你的这个代码我本来是想要的,算了。
说我不大方啊!怎么看的出?呵呵,急我给你分吧!
就这句话,就给你一点分吧!
开个玩笑 :)To:All Friends
谢谢各位的帮助!!
对了,我是想做加密用的啊!你不会就因为这个就认为……
如果是这样认为就是你不对了哦!我只是初学而已,对任何事物都想知道,你不会认为做了加密的人就是不大方的人吧!而且加密也是一个程序的哦!如果是这样,你以后不要小心眼哦!做程序员要怎样做,你应该知道。
如果有说错的地方,对不起啊!