Link to home
Start Free TrialLog in
Avatar of nhhlplmj
nhhlplmj

asked on

the serial number of cpu and hard disk

how to get the serial number of cpu(pII and pIII or K serials) and hard disk  in my delphi program?
Avatar of rwilson032697
rwilson032697

Use this to get the serial number:

procedure TForm1.Button1Click(Sender: TObject);var  SerialNum : pdword;
  a, b : dword;  
Buffer  : array [0..255] of char;
begin
if GetVolumeInformation('c:\', Buffer, SizeOf(Buffer), @SerialNum, a, b,
nil, 0) then
Label1.Caption := IntToStr(SerialNum^);
end;

(Of the hard disk that is...)

ASKER CERTIFIED SOLUTION
Avatar of simonet
simonet
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ALEX......!

Close enough, Raymond!

nhhlplmj, here's a little addendum to my answer:
You cannot retrieve the serial number of CPU's. The serial number that's actually printed on the CPU is only an external indication.

However, if you need to uniquely identify a computer, then there are other things you can do (use them all together):
1) Use the motherboard serial number
2) Use several parameters of the CPU, like vendor, speed, Stepping, Model, etc
3) Use the NIC number

I've written components that will let you retrieve all that information from the machine. All the components are freeware and you can download them from my site:
Athena's Place: http://www.bhnet.com.br/~simonet
(Just go to the AS OmniTools page and download the components. If you have Delphi 3, go to the AS PowerTools page).

Yours,

Alex
Chill, Ray! I am just following Darin's advice (remember?) on your own thread on the Cust. Serv. area.

Alex
No I don't remember - can you point me at the thread (I've had a look in the area and can't see any relevant threads of mine...

Cheers,

Raymond.
The one about a question that was deleted. Actually I don't know if Darin posted the reply to my or to your question, since we both had questions describing similar problems.

Alex
Nope - you've got me there Alex. What was the problem the question was relating to?

Cheers,

Raymond.

To those who believe you can't get the CPU Serial number, your only *partically* right.

To get the Processor Serial number of a Pentium (R) III (tm) processor, it is possible... as long as the user/OEM hasn't perm. disabled it. Prior to the P3, there is not PSN.

This information is available from Intel's WWW site... I just don't remember where I got it.

In Assembly, you do a CPUID call with EAX=03h.

It returns the Serial number in a combination of 4 Exx registers, You'll need to find the documentation on www.intel.com. To be exact: <a href ="http://developer.intel.com/design/pentiumii/applnots/241618.htm">http://developer.intel.com/design/pentiumii/applnots/241618.htm</a>. <i>hope the html works</i>

I do not think Delphi's Compiler understands the CPUID call under ASM end; blocks but I could be mistaken.

Hope this helps,
John
www.zittware.com
Avatar of nhhlplmj

ASKER

Simonet,
  thanks for your suggestion.
but your ASCpuInfo component can't work. when i run the program with TASCpuInfo,it raises an exception class EConvert Error with message '07/29/98',it says that '07/29/98' is not a valid date.why?
nhhlplmj,

I know what's going wrong. I'll be working on that this afternoon and posting an updated component. Thanks for notifying me.

Alex
  thanks ,alex, I will check your updated component this afernoon.
   by the way,how to get the NIC number ?

by nhhlplmj
>by the way,how to get the NIC number ?

The code that follows is one of the many methods there are to retrieve the NIC number. If it doesn't work for you, let me know and I'll post another. However, AFAIK, this one is the fastest and doesn't require any additional units to the project.

>I will check your updated component this afernoon.

I can only upload the new version it to my ISP Wednesday afternoon (in Brazil's time). Please be just a little bit patient. Thanks.

Alex

*********

function CoCreateGuid(P:Pointer):Integer;stdcall;external 'ole32.dll';

function GetNicAddr:AnsiString;
var
  T:AnsiString;
  I:Integer;
begin
  Result:='';
  SetLength(T,16);
  if CoCreateGUID(@T[1])=S_OK then begin
    for I:=11 to 15 do Result:=Result+IntToStr(Ord(T[I]))+'.';
    Result:=Result+IntToStr(Ord(T[16]));
  end;
end;

nhhlplmj,

If you use Delphi 4.03, you can already download the updated version of TASCpuInfo and TASSysInfo (both part of the AS OmniTools suite).

The components for Delphi 3 (ASPowerTools) will be updated in about 1 hour.

Alex
All components (AS OmniTools and AS PowerTools) have been updated and are available for immediate download.

Yours,

Alex
Athena's Place: http://www.bhnet.com.br/~simonet