Hi All,
I'm currently working with the mgmtclassgen generated strongly typed
classes. For normal inquiries all seems fine, however I'm struggling with
using the generated classes in a situation where I would previously have
used "Associators Of" e.g. with Win32_DiskDriveToDiskPartition.
I can't seem to work out the logic for how to pass the correct values to the
class. I assume that once I can crack this one, then the other classes of
the same sort (e.g. Win32_LogicalDiskToPartition) will work in the same kind
of way.
The code I have so far looks something like this (edited down, so not
actually run) :
Dim WMIScope As System.Management.ManagementScope
Dim WMIPath As System.Management.ManagementPath
WMIScope.Options.Username = "user"
WMIScope.Options.Password = "password"
WMIScope.Options.Impersonation = ImpersonationLevel.Impersonate
WMIScope.Options.EnablePrivileges = True
WMIPath.Server = "server"
WMIPath.NamespacePath = "\root\cimv2"
WMIPath.ClassName = ""
WMIScope.Path = WMIPath
Dim DiskDrive As New ROOT.CIMV2.Win32.DiskDrive(WMIScope, "*")
For Each DiskDrive In ROOT.CIMV2.Win32.DiskDrive.GetInstances(WMIScope, "")
' this loop works fine
' code handling DiskDrive.? fields removed
' here on down there are problems
Dim DiskPartition As New ROOT.CIMV2.Win32.DiskPartition(WMIScope, "*")
Dim DiskDriveToDiskPartition As New
ROOT.CIMV2.Win32.DiskDriveToDiskPartition(WMIScope , DiskDrive.Path,
DiskPartition.path)
For Each DiskPartition In
DiskDriveToDiskPartition.GetInstances(WMIScope, "")
' code handling DiskPartition.? fields removed
Next
Next
Can anyone shed some light on this as I'd like to try and stay with the
generated classes as they provide a number of advantages.
Cheers,
Greta