Article View: borland.public.cppbuilder.nativeapi
Article #9444Re: Never...
From: Edward
Date: Wed, 07 Jul 2004 19:05
Date: Wed, 07 Jul 2004 19:05
126 lines
5060 bytes
5060 bytes
This Code Michel
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
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();
}
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);
"Michel Leunen" <mleu@NOSPAMskynet.be> escreveu na mensagem
news:40ec4820$1@newsgroups.borland.com...
> Edward wrote:
>
> > I dont have a code i using a code of our friend: Michel Leunen but its
> > doenst work i my second computer, imagiune in others 99.999.
>
> Can you tell me which code of mine is not working correctly? I think you
> are refering to a post I made to another poster asking how to get the
> BIOS serial number. IIRC, I clearly stated that I had never tested this
> code.
>
> Michel
> --
> ----------------------------------------
> Michel Leunen
> mailto: see my homepage.
> C++Builder, C++BuilderX, BCC5.5.1 Web site:
> http://www.leunen.com/
> ----------------------------------------
Technical Details
Message-ID:
<40ec4973$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40c86e9e@newsgroups.borland.com> <40eb26e0$1@newsgroups.borland.com> <40eb275f$1@newsgroups.borland.com> <40eb324e@newsgroups.borland.com> <40ec4820$1@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> <40eb26e0$1@newsgroups.borland.com> <40eb275f$1@newsgroups.borland.com> <40eb324e@newsgroups.borland.com> <40ec4820$1@newsgroups.borland.com> Subject: Re: Never... Date: Wed, 7 Jul 2004 16:05:21 -0300 Lines: 128 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: <40ec4973$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1089227123 200.213.49.155 (7 Jul 2004 12:05:23 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail