PDA

View Full Version : How dotNet "System.Management.ManagementObjectSearcher" work?


fudongmu
10-04-2008, 11:03 PM
I cant get the device array,how does dotnetclass "System.Management.ManagementObjectSearcher" work?
mytemp=my.get()
cant get an array value ,then i try to use this code
temp=#()
--temp.count=2
mindex=1
integer mindex
mytemp.copyto temp mindex
return error message "index out of range" , i need some help,i have no idea to try
this is the code
dotNet.loadAssembly "System.Management"
mydot=dotNetclass "System.Management.ManagementObjectSearcher"
showproperties mydot
--showmethods mydot
my=dotnetobject mydot
showProperties my showStaticOnly:false showMethods:true showAttributes:true

my.query.QueryString="SELECT * FROM Win32_DiskDrive"
mytemp=my.get()
showmethods mytemp showStaticOnly:false showMethods:true showAttributes:true
mytemp.count
temp=#()
--temp.count=2
mindex=1
integer mindex
mytemp.copyto temp mindex

drdubosc
10-05-2008, 01:30 AM
I'm not an expert in how MXS relates to dotnet yet, but .copyto requires its destination array to be 0-based, and Max arrays are 1-based. You could use the dotnet collection's own supplied enumerator, thus ...




dotNet.loadAssembly "System.Management"

MOS_Class = dotNetclass "System.Management.ManagementObjectSearcher"
myMOS = dotnetobject MOS_Class

myMOS.query.QueryString = "SELECT * FROM Win32_DiskDrive"
myMOC = myMOS.get()

myMOCEnum = myMOC.GetEnumerator()

myMaxArr = #()

while (myMOCEnum.MoveNext()) do(
append myMaxArr myMOCEnum.Current
)

for myMO in myMaxArr do (
deviceid = myMO.GetPropertyValue("deviceid")
print deviceid
)


.. but maybe an expert will come up with a better way

CGTalk Moderation
10-05-2008, 01:30 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.