Reprinted please keep this article link: http://blog.csdn.net/sushengmiyan/article/details/8545673
{Hardware Author: sushengmiyan 2013.01.26 remarks: function: hardware information retrieval unit Units units} unit applicationhardwareinfo; interfaceuses windows, sysutils, classes, registry, nb30, Winsock; Type tcpuid = array [1 .. 4] of longint; function getcpuid: tcpuid; assembler; register; Type // cpuid Information Class tcpuidinf O = class private fcpuid: tcpuid; fcpuidstr: string; Procedure setcpu (ahandle: thandle; cpuno: integer); function cpuidtostr (acpuid: tcpuid): string; function getcomputerbasicfrequency: String; function getcputype: string; Public Function getcpuidstr: string; property cpufrequency: String read getcomputerbasicfrequency; property processortype: String read getcputype; constructor create; end; // Mac Address information class tmacadressinfo = class private fmacadress: string; function getmacphysicaladdress (Alana: integer = 0): string; function getmacaddress: string; public property macadrress: String read getmacaddress; constructor create; end; // user information class tpcuserinfo = class private function GetUserName: string; function gethostip: string; function getwindowsvertion: string; public property Username: String read get Username; property hostip: String read gethostip; property windowsvertion: String read getwindowsvertion; constructor create; end; implementation {tcpuidinfo} {author \-Author: sushengmiyan 2013.01.26 parameter: none returned: tcpuid function: Obtain cpuid \ -----------------------------------------------------------------------------------} function getcpuid: tcpuid; M push EBX {save affected register} Push EDI mov EDI, eax {@ resukt} mov eax, 1 DW $ a20f {cpuid command} stosd {cpuid [1]} mov eax, EBX stosd {cpuid [2]} mov eax, ECx stosd {cpuid [3]} mov eax, EDX stosd {cpuid [4]} pop EDI {restore registers} pop ebxend; {author \-Author: sushengmiyan 2013.01.26 parameter: acpuid: tcpuid return: String function: Convert hexadecimal cpuid to string \--- --------------------------------------------------------------------------} Function tcpuidinfo. cpuidtostr (acpuid: tcpuid): string; begin result: = ''; Result: = inttohex (acpuid [1], 8) + inttohex (acpuid [2], 8) + inttohex (acpuid [3], 8) + inttohex (acpuid [4], 8); end; {author \-Author: sushengmiyan 2013.01.26 parameter: none return: String function: processor type \---- -------------------------------------------------------------------------} Function tcpuidinfo. getcputype: string; var systeminfo: system_info; begin // get the CPU model getsysteminfo (systeminfo); Result: = inttostr (systeminfo. dwprocessortype) end; {response \-Author: sushengmiyan 2013.01.26 parameter: none return: String function: CPU frequency \------------------------------------ -----------------------------------------} Function tcpuidinfo. priority: string; const delaytime = 500; var timerhi, timerlo: DWORD; priorityclass, priority: integer; dspeed: Double; begin priorityclass: = getpriorityclass (getcurrentprocess); priority: = getthreadpriority (getcurrentthread); setpriorityclass (getcurrentprocess, realtime_priority_class); setthreadpriority (getcurrentthrea D, thread_priority_time_critical); sleep (10); asm dw 310fh // rdtsc command mov timerlo, eax mov timerhi, EDX end; sleep (delaytime ); asm dw 310fh // rdtsc sub eax, timerlo SBB edX, timerhi mov timerlo, eax mov timerhi, EDX end; setthreadpriority (getcurrentthread, priority); Combine (getcurrentprocess, priorityclass); dspeed: = timerlo/(1000.0 * delaytime); Result: = formatfloat ('0. 00', dspeed /1024) + 'ghz; end; {consumer \-Author: sushengmiyan 2013.01.26 parameter: aowner: tcomponent return: None function: initialization \ consumer} constructor tcpuidinfo. create; begin fcpuid: = getcpuid; fcpuidstr: = cpuidtostr (fcpuid); end ;{------------------------------------------------------------------- --------- \-Author: sushengmiyan 2013.01.26 parameter: none return: String cpuid string function: external function. Call this method to obtain the cpuid \ signature} function tcpuidinfo. getcpuidstr: string; begin setcpu (getcurrentprocess, 1); Result: = cpuidtostr (getcpuid); end; {author \-Author: sushengmiyan 2013.01.26 parameter: ahandle: thandle; Cpuno: integer return: None function: set which CPU is the first by default (recommended) \ -------------------------------------------------------------------------------} procedure tcpuidinfo. setcpu (ahandle: thandle; cpuno: integer); var processaffinity: Cardinal; _ systemaffinity: Cardinal; begin // set affinity of processes or threads ), make the process or thread run getprocessaffinitymask (ahandle, processaffinity, _ systemaffinity) on the specified CPU (CORE); processaffinity: = cpuno; setprocess Affinitymask (ahandle, processaffinity); end; {tmacadressinfo} {author \-Author: sushengmiyan 2013.01.26 parameter: none return: None function: initialization \ signature} constructor tmacadressinfo. create; begin fmacadress: = getmacphysicaladdress; end ;{----------------------------------------------------- ----------------------- \-Author: sushengmiyan 2013.01.26 parameter: none return: String function: Return MAC address \ signature} function tmacadressinfo. getmacaddress: string; begin result: = fmacadress; end; {author \-Author: sushengmiyan 2013.01.26 parameter: Alana: integer = 0 return: String function: obtain the Mac physical address (in memory) by using the Lana number. The overall step is as follows: Steps: 1. List all available Lana numbers on the System II. Each Lana number used in the reset Plan III. Obtain the NIC address \ Users} function tmacadressinfo by using the adapter command. getmacphysicaladdress (Alana: integer = 0): string; var NCB: tncb; // NetBIOS control block adapterstatus: tadapterstatus; // obtain the NIC status lanaenum: tlanaenum; // Lana enumerated value I: integer; begin result: = ''; try {http://blog.csdn.net/sushengmiyan/article/details/8543811 1, Enumerative Lana value ①. apply to allocate a tncb structure NCB: tncb; ②. initialize the tncb structure variable to o zeromemory (@ NCB, sizeof (NCB); ③. set the command to ncbenum NCB. ncb_command: = CHR (ncbenum); ④. assign lana_enum NCB to ncb_buffer. ncb_buffer: = @ lanaenum; ⑤. specify the length NCB for ncb_length. ncb_length: = sizeof (lanaenum); 6. call the NetBIOS function to obtain NetBIOS CRC: = NetBIOS (@ NCB); 7. the returned value nrc_goodret indicates successful NCB. ncb_retcode = CHR (nrc_goodret)} zeromemory (@ NCB, sizeof (NCB); NCB. ncb_command: = CHR (NCB Enum); NCB. ncb_buffer: = @ lanaenum; NCB. ncb_length: = sizeof (lanaenum); NetBIOS (@ NCB); if not (NCB. ncb_retcode = CHR (nrc_goodret) Then exit; {http://blog.csdn.net/sushengmiyan/article/details/8543811 2. Reset each Lana number used by the scheduler ①. apply to allocate a tncb structure NCB: tncb; ②. initialize the tncb structure variable to o zeromemory (@ NCB, sizeof (NCB); ③. set the command to ncbreset NCB. ncb_command: = CHR (ncbreset); ④. set the Lana number NCB for the command. ncb_lana_num: = lanaenum. lana [Alana]; ⑤. Call the NetBIOS function to obtain NetBIOS CRC: = NetBIOS (@ NCB); 6. the returned value nrc_goodret indicates successful NCB. ncb_retcode = CHR (nrc_goodret)} zeromemory (@ NCB, sizeof (NCB); NCB. ncb_command: = CHR (ncbreset); NCB. ncb_lana_num: = lanaenum. lana [Alana]; NetBIOS (@ NCB); if not (NCB. ncb_retcode = CHR (nrc_goodret) Then exit; {http://blog.csdn.net/sushengmiyan/article/details/8543811 3. Get the NIC address using the tadapterstatus structure ①. apply to allocate a tncb structure NCB: tncb; ②. set TNC The B structure variable is initialized to o zeromemory (@ NCB, sizeof (NCB); ③. set the command to ncbastat NCB. ncb_command: = CHR (ncbastat); ④. assign lana_enum NCB to ncb_buffer. ncb_buffer: = @ lanaenum; ⑤. set ncb_callname NCB. ncb_callname: = '*' + #0; 6. assign adapterstatus NCB to ncb_buffer. ncb_buffer: = @ adapterstatus; 7. specify the length NCB for ncb_length. ncb_length: = sizeof (adapterstatus); optional. call the NetBIOS function to obtain NetBIOS CRC: = NetBIOS (@ NCB);} zeromemory (@ NCB, sizeof (NCB); NCB. n Cb_command: = CHR (ncbastat); NCB. ncb_lana_num: = lanaenum. lana [Alana]; NCB. ncb_callname [0]: = '*'; // Why is this setting not clear? * indicates what? // Understand can mail share 429119108@qq.com O (∩ _ ∩) O Thank you NCB. ncb_buffer: = @ adapterstatus; NCB. ncb_length: = sizeof (adapterstatus); NetBIOS (@ NCB); // obtain the MAC physical address string in the form of a AA-BB-CC-DD-EE-FF result: = ''; for I: = 0 to 5 do if samestr (result, '') then result: = Result + inttohex (INTEGER (adapterstatus. adapter_address [I]), 2) else result: = Result + '-' + inttohex (INTEGER (adapterstatus. adapter_address [I]), 2); finally end; {tpcuserinfo} {author \-Author: sushengmiyan 2013.01.26 parameter: none return: None function: Create \ role} constructor tpcuserinfo. create; beginend; {response \-Author: sushengmiyan 2013.01.26 parameter: none return: String function: Obtain Host IP \ response} function tpcuserinfo. gethostip: string; var shostname: string; wsadata: twsadata; hostent: phostent; begin shostname: = username; Result: = ''; wsastartup (2, wsadata); hostent: = gethostbyname (pchar (shostname); If hostent <> nil then begin with hostent ^ do result: = format ('% d. % d. % d. % d', [byte (h_addr ^ [0]), byte (h_addr ^ [1]), byte (h_addr ^ [2]), byte (h_addr ^ [3]); end; wsacleanup; end; {response \-Author: sushengmiyan 2013.01.26 parameter: none return: None function: obtain the USERNAME \ ---------------------------------------------------------------------------} function tpcuserinfo. getUserName; var name: pchar; Size: DWORD; begin getmem (name, 255); // applied memory size: = 255; getcomputername (name, size); Result: = Name; freemem (name); // remember to release the memory end; {response \-Author: sushengmiyan 2013.01.26 parameter: none return: String function: Return OS type \ response} function tpcuserinfo. getwindowsvertion: string; function getwindowsversionstring: string; var osversion: tosversioninfoa; begin result: = ''; osversion. dwosversioninfosize: = sizeof (tosversioninfoa); If getversionexa (osversion) then with osversion do result: = trim (format ('% s', [szcsdversion]); end; var awin32version: extended; swin: string; begin swin: = 'windows'; awin32version: = strtofloat (format ('% d. % d', [win32majorversion, win32minorversion]); Case win32platform of ver_platform_win32s: Result: = swin + '32'; ver_platform_win32_windows: Begin if awin32version = 4.0 then result: = swin + '95' else if awin32version = 4.1 then result: = swin + '98 'else if awin32version = 4.9 then result: = swin + 'me' else result: = swin + '9x'; end; ver_platform_win32_nt: Begin if awin32version = 3.51 then result: = swin + 'nt 100' else if awin32version = 3.51 then result: = swin + 'nt 100' else if awin32version = 4.0 then result: = swin + '000000' else if awin32version = 5.0 then result: = swin + 'xp 'else if awin32version = 5.2 then result: = swin + '000000' else if awin32version = 2003 then result: = swin + 'Vista 'else if awin32version = 6.1 then result: = swin + '7' else result: = swin; end; Result: = Result + ''+ getwindowsversionstring; end.
Share the source code. I hope you can give me some additional information. (* ^__ ^ *)
Free: http://download.csdn.net/detail/sushengmiyan/5032146