Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Dec 09, 2019 6:06 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: MBS Win Hdd Info Example
PostPosted: Thu Jul 01, 2010 3:21 pm 
Offline

Joined: Mon Apr 19, 2010 12:58 pm
Posts: 92
Hi,

The Win WMI HDD Info example returns details for the main drive, will it also show these details for a usb stick.

If it can how do I change the drive assignment in the example( for instance M:\).

dim s as string

eVSerialNumber.text="n/a"
eSerialNumber.text="n/a"

if TargetWin32 then
w=new WindowsWMIMBS

if w.ConnectServer("root\cimv2") then
if w.query("WQL","Select * from Win32_DiskDrive") then
if w.NextItem then // first only

eCaption.text=w.GetProperty("Caption")
eDescription.text=w.GetProperty("Description")
eDeviceID.text=w.GetProperty("DeviceID")
eInterfaceType.text=w.GetProperty("InterfaceType")
eManufacturer.text=w.GetProperty("Manufacturer")
eModel.text=w.GetProperty("Model")
eName.text=w.GetProperty("Name")
eSize.text=w.GetProperty("Size")
eSystemName.text=w.GetProperty("SystemName")

end if
else
MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if

else
MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if

w=new WindowsWMIMBS

if w.ConnectServer("root\cimv2") then
if w.query("WQL","Select * from Win32_PhysicalMedia") then
while w.NextItem // find the first serial number known
s=w.GetProperty("SerialNumber")
if s<>"" then
eSerialNumber.text=s
exit // got one
end if
wend
else
MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if

else
MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if


w=new WindowsWMIMBS

if w.ConnectServer("root\cimv2") then
if w.query("WQL","Select * from Win32_LogicalDisk") then
while w.NextItem // find the first volume serial number known
s=w.GetProperty("VolumeSerialNumber")
if s<>"" then
eVSerialNumber.text=s
exit
end if
wend
else
MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if

else
MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if

w=new WindowsWMIMBS

if w.ConnectServer("root\cimv2") then
if w.query("WQL","Select * from Win32_SystemEnclosure") then
while w.NextItem // find the system serial number
s=w.GetProperty("SerialNumber")
if s<>"" then
eMSerialNumber.text=s
exit
end if
wend
else
MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if

else
MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if
else
MsgBox "This example is for Windows only."
end if


Regards John


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Win Hdd Info Example
PostPosted: Fri Jul 02, 2010 5:58 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Well, as you see there is the NextItem call to move over the list of drives.
Of course you should know, that drive letters are assigned to logical drives. Now a physical drive may have a couple of logical drives on it. So matching for example a hard disc serial number to a drive letter can be difficult.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Win Hdd Info Example
PostPosted: Fri Jul 02, 2010 12:36 pm 
Offline

Joined: Mon Apr 19, 2010 12:58 pm
Posts: 92
Hello Christian,
Thanks for the reply but I do not understand what you are saying, the example shows the main physical drive only,how does it get a different drive.

Regards
John


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Win Hdd Info Example
PostPosted: Fri Jul 02, 2010 1:00 pm 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Make it a loop working on all items in the list.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Win Hdd Info Example
PostPosted: Sat Jul 03, 2010 2:27 am 
Offline

Joined: Mon Apr 19, 2010 12:58 pm
Posts: 92
Hi Christian,

I do not see how or what to loop.
Cutting the code down to this:

Dim SerialNumber As String
w = New WindowsWMIMBS

If w.ConnectServer("root\cimv2") Then

If w.query("WQL","SELECT * FROM Win32_PhysicalMedia") Then

While w.NextItem

SerialNumber = w.GetPropertyString("SerialNumber")
If SerialNumber <> "" Then Exit

Wend
End
End


MsgBox SerialNumber


Again it is the main drive, so it appears to be the connection that needs to change is ("root\cimv2") but without knowing the syntax available i am stuck. Could the query have a where statement i.e WHERE DRIVEID = for instance.
Reading the documentation on your class does not provide any clues.

Regards
John


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group