🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9515

Last trie

#9515
From: Edward
Date: Wed, 07 Jul 2004 00:02
221 lines
6839 bytes
It is not resonably possible to obtain such serial numbers.  I've looked
into this in the past, and found it incredibly difficult.  Most BIOSes and
motherboards don't have unique serial numbers, only BATCH numbers (which are
not unique).  And even those numbers are stored differently from
manufacturer to manufacturer, which makes it very difficult, and not worth
the effort since the number isn't unique.  What I wound up doing, was
something much simpler, but just as effective.


I test this codes:

1)
reading


registry -> HKEY_LOCAL_MACHINE

for Win95:  SubKey := 'enum\root\*PNP0C01\0000';
for WinNt:  SubKey := 'hardware\description\system';


  AnsiString VersaoBios;
  char biosnro[60];
  int i;
  TRegistry *Reg;

  i=0;
  while(i < sizeof(biosnro))
  {
    biosnro[i] = ' ';
    i++;
  }

  try
  {
    Reg = new TRegistry;
  }
  catch(...)
  {
    MessageDlg("AUTORUN ERROR! - Code: 001", mtError, TMsgDlgButtons() <<
mbOK, 0);
  }
  Reg->RootKey = HKEY_LOCAL_MACHINE;
  Reg->OpenKey("\\HARDWARE\\DESCRIPTION\\System", false);
  if(Reg->KeyExists("\\HARDWARE\\DESCRIPTION\\System"))
  {
     Reg->ReadBinaryData("SystemBiosVersion",&biosnro,sizeof(biosnro));

    i=0;
    while(i < sizeof(biosnro)-1)
    {
      if(biosnro[i] == '\0'){
        VersaoBios = VersaoBios + AnsiString(" # ");
      }
      else{
        VersaoBios = VersaoBios + AnsiString(biosnro[i]);
      }
      i++;
    }
    MemoLOG->Lines->Add(AnsiString("Versao BIOS: ") +
AnsiString(VersaoBios));
  }
  Reg->CloseKey();
  delete Reg;

    It doenst work because some times the datavaleu os "SystemBiosVersion"
are REG_MULTI_SZ other times REG_SZ and other times are Unknow type i try to
use RegQueryValueEx to read the type but dont work to.






2)

I found this but i cant translate to Builder C++ i think its to print a
adress of memory:

in win98 use PChar( Ptr( $FEC51 ) ) can get bios serial no, in w2k how do
it?





3) Work fie in my first computer but in second with windows 98 no way the
error message was "sequence of invalid class".


this is result of my computer:

Caption: Award Modular BIOS v6.0
Name: Award Modular BIOS v6.0
Description: Award Modular BIOS v6.0
Manufacturer: Award Software, Inc.
Serial Number: SYS-1234567890
Status: OK
Version: ASUS   - 42302e31
Current Language: en|US|iso8859-1


  Variant locator = Variant::CreateObject("WbemScripting.SWbemLocator");
  if(locator.IsNull())
  {
    Application->Terminate();
    ShowMessage("Could not connect to SWbemLocator");
  }

  //Get SWbemServices
  Variant srv=locator.Exec(Function("ConnectServer"));
  if(srv.IsNull())
  {
    Application->Terminate();
    ShowMessage("Could not connect to SWbemServices");
  }

  //Setting security attributes
  Variant Secure=srv.Exec(Function("Security_"));
  if(Secure.IsNull())
  {
    Application->Terminate();
    ShowMessage("Could not get Security_ property of SWbemServices");
  }

  //Set ImpersonationLevel in wbemImpersonationLevelImpersonate
  Secure.Exec(PropertySet("ImpersonationLevel") << 3);

  //Method InstancesOf creates an enumerator that returns the instances of a
  //specified class according to user-specified selection criteria
(Win32_BIOS)
  Variant WbemBIOS=srv.Exec(Function("InstancesOf") << "Win32_BIOS");
  if(WbemBIOS.IsNull())
  {
    Application->Terminate();
    ShowMessage("Could not get instance Win32_BIOS enumerator");
  }

  //How much object in the collection:
  int lcount=WbemBIOS.Exec(PropertyGet("Count"));
  if(lcount != 1)
  {
    ShowMessage("Only one instance!");
    Application->Terminate();
  }
  /*
          //---- placas redes
        LPUNKNOWN punkEnum;
        IEnumVARIANT FAR* penum;
        int lcount;
        VARIANT NetAdapter;
*/
  VARIANT BIOS;
  Variant vRet, v;

  LPUNKNOWN punkEnum;
  IEnumVARIANT * penum=NULL;
  int nIndex;

  unsigned long cc;

  //Prepare for enumerate
  punkEnum =WbemBIOS.Exec(PropertyGet("_NewEnum"));
  punkEnum->QueryInterface(IID_IEnumVARIANT, (LPVOID FAR*)&penum);
  penum->AddRef();
  punkEnum->Release();

  VariantInit(&BIOS);
  //Get object:
  penum->Next(1,&BIOS,&cc);
  if(BIOS.vt == 0)
  {
    ShowMessage("No instance of Win32_BIOS class");
    Application->Terminate();
  }
  penum->Release(); //free interface

  Variant result;

  //Obtaining properties of Win32_BIOS instance:
  result=(Variant(BIOS.pdispVal)).Exec(PropertyGet("Caption"));
  if(!result.IsNull()){
    MemoLOG->Lines->Add(AnsiString("Caption: ") + AnsiString(result));
  }
  result=(Variant(BIOS.pdispVal)).Exec(PropertyGet("Name"));
  if(!result.IsNull()){
    MemoLOG->Lines->Add(AnsiString("Name: ") + AnsiString(result));
  }
  result=(Variant(BIOS.pdispVal)).Exec(PropertyGet("Description"));
  if(!result.IsNull()){
    MemoLOG->Lines->Add(AnsiString("Description: ") + AnsiString(result));
  }
  result=(Variant(BIOS.pdispVal)).Exec(PropertyGet("Manufacturer"));
  if(!result.IsNull()){
    MemoLOG->Lines->Add(AnsiString("Manufacturer: ") + AnsiString(result));
  }
  result=(Variant(BIOS.pdispVal)).Exec(PropertyGet("SerialNumber"));
  if(!result.IsNull()){
    MemoLOG->Lines->Add(AnsiString("Serial Number: ") + AnsiString(result));
  }
  result=(Variant(BIOS.pdispVal)).Exec(PropertyGet("Status"));
  if(!result.IsNull()){
    MemoLOG->Lines->Add(AnsiString("Status: ") + AnsiString(result));
  }
  result=(Variant(BIOS.pdispVal)).Exec(PropertyGet("Version"));
  if(!result.IsNull()){
    MemoLOG->Lines->Add(AnsiString("Version: ") + AnsiString(result));
  }
  result=(Variant(BIOS.pdispVal)).Exec(PropertyGet("CurrentLanguage"));
  if(!result.IsNull()){
    MemoLOG->Lines->Add(AnsiString("Current Language: ") +
AnsiString(result));
  }
  VariantClear(&BIOS);




I dont know what more i can do.

Edward.
Technical Details
Message-ID: <40eb41eb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40c86e9e@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e3066f787953dff9
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Edward" <Registrados2004@aol.com>
From: "Edward" <Registrados2004@aol.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40c86e9e@newsgroups.borland.com>
Subject: Last trie
Date: Tue, 6 Jul 2004 21:02:21 -0300
Lines: 224
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 200.213.49.155
Message-ID: <40eb41eb$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1089159659 200.213.49.155 (6 Jul 2004 17:20:59 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail