Notifications
Clear all
[Closed] How dotNet "System.Management.ManagementObjectSearcher" work?
Oct 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
1 Reply
Oct 04, 2008 11:03 pm
I’m not an expert in how MXS relates to dotnet yet, but .copyto [font=Verdana]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 …
[/font]
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
[font=Verdana]
[/font]