Delphi - No. de serie del board

 
Vista:

No. de serie del board

Publicado por G@rgol (18 intervenciones) el 26/04/2006 20:54:08
Como puedo leer el número de serie de la motheboard desde delphi? Existe alguna API de Windows que de ese número o alguna función para ello?

de antemano gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:No. de serie del board

Publicado por Nitrus (11 intervenciones) el 08/05/2006 11:33:59
Esta la tome de otra web, No funciona en Windows 95, 98 y ME

Well I would use WMI (Windows Management Instrumentation) to get all of those Hardware related things...

// This function performs a Windows Management Instrumentation (WMI) query.
// You send it a Class (like 'Win32_BIOS') and a property (like 'SerialNumber')
// A few common classes and serial numbers are commented on further below.
//
// To use this function, you need to include ActiveX, WbemScripting_TLB
// in your uses statement. You may also have to import this type library:
//
// Microsoft WMI Scripting v1.1 Library (Version 1.1)
//
// In Delphi, go to Project/Import Type Library and Install it (This installs
// the WbemScripting_TLB library on your ActiveX tab)
//
// This function will not run on Windows 95, 98, and NT 4 unless you've
// installed the WMI Core components from Microsoft. Go to
// http://www.microsoft.com/downloads/search.asp?
// and do a Keyword search for "WMI" (sans quotes). Make sure you select
// All Downloads in the "Show Results For" box. You want the file labeled
// Windows Management Instrumentation (WMI) CORE 1.5 (Windows 95/98/NT 40)
// Version 1.5 dated Feb. 11, 2000 (the lastest as of this writing)
// This code was originally written by Denis Blondeau

An short Example:

function GetWMIstring (wmiHost, wmiClass, wmiProperty : string):string;
var // These are all needed for the WMI querying process
Locator: ISWbemLocator;
Services: ISWbemServices;
SObject: ISWbemObject;
ObjSet: ISWbemObjectSet;
SProp: ISWbemProperty;
Enum: IEnumVariant;
Value: Cardinal;
TempObj: OleVariant;
SN: string;
begin
try
Locator := CoSWbemLocator.Create;
Services := Locator.ConnectServer(wmiHost, 'root\cimv2', '', '', '','', 0, nil);
ObjSet := Services.ExecQuery('SELECT * FROM '+wmiClass, 'WQL',
wbemFlagReturnImmediately and wbemFlagForwardOnly , nil);
Enum := (ObjSet._NewEnum) as IEnumVariant;
while (Enum.Next(1, TempObj, Value) = S_OK) do
begin
SObject := IUnknown(tempObj) as ISWBemObject;
SProp := SObject.Properties_.Item(wmiProperty, 0);
if VarIsNull(SProp.Get_Value) then
result := ''
else
begin
SN := SProp.Get_Value;
result := SN;
end;
end;
except
on exception do
result := '';
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var tmpstr : string;
T,M,Y,A : String;
begin

with form1 do begin
tmpstr := getWMIstring('','Win32_BIOS','SerialNumber');
if tmpstr <> '' then
label6.caption := tmpstr
else
label6.Caption := 'No Disponible';

tmpstr := getWMIstring('.','Win32_BIOS','Manufacturer');
if tmpstr <> '' then
label5.caption := tmpstr
else
label5.Caption := 'No Disponible';
tmpstr := getWMIstring('','Win32_ComputerSystemProduct','Name');
if tmpstr <> '' then
label4.caption := tmpstr
else
label4.Caption := 'No Disponible';
tmpstr := getWMIstring('','Win32_BIOS','Status');
if tmpstr <> '' then
label8.caption := tmpstr
else
label8.Caption := 'No Disponible';
tmpstr := getWMIstring('','Win32_BIOS','SMBIOSBIOSVERSION');
if tmpstr <> '' then
label10.caption := tmpstr
else
Label10.Caption:='No Disponible';
tmpstr := getWMIstring('','Win32_BIOS','ReleaseDate');
if tmpstr <> '' then
begin
Y:=Copy(tmpstr,0,4);
T:=Copy(tmpstr,5,2);
M:=Copy(tmpstr,7,2);
Label12.Caption:=M+'.'+T+'.'+Y;//tmpstr
end
else
Label12.Caption:='No Disponible';
end;
end;

end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar