ManagementClass 是否加载所有属性?
Does ManagementClass load all of the properties?
使用 ManagementObjectSearcher 时 - 可以搜索特定属性(而不是通过 *
搜索所有属性)。
实例化ManagementClass(即new ManagementClass(someClass)
)时会发生什么,它加载所有属性,还是只是某种指针,不会加载属性?
.
(我也很高兴知道将 ManagementObjectSearcher
与 *
一起使用时会发生什么,它会加载属性以外的任何内容,还是就像指定所有这些都是明确的吗?从逻辑上讲,它应该只是表示 "all",但从 here 看来并非如此。)
实例化它时没有任何反应。它只是 stores the query, scope and whatever else you may have specified。 ManagementObjectSearcher
也一样
当您调用 .Get()
、the query is executed against the current scope. As for ManagementObjectSearcher
, the actual behavior depends on whether it's a class enumeration or instance enumeration (e.g. a query)
执行查询并直接获得 return 结果(任何属性),而 class 枚举将绑定到基础 WMI 对象 without actually loading anything,直到您调用 .Get()
某处。
does it load all of the properties, or is it only some sort of pointer
它是一个 pointer to the CIM Object Manager. The underlying objects are only loaded when initialize is called with true(表示您要绑定到基础 WMI 对象)。这是执行查询的对象。
查看对 Initialize()
的各种调用,乍一看似乎只有在您请求属性或限定符时才绑定对象。调用方法不会绑定它们。
I'd also be happy to know what happens when using ManagementObjectSearcher with a *
在您执行查询之前什么都没有。默认情况下,对对象执行 shallow enumeration。除了属性之外,这可能 return 限定符,但我对此并不完全确定。
也很有趣(包括兄弟文章):https://technet.microsoft.com/en-us/library/cc180561.aspx
我希望这对您有所帮助:)
使用 ManagementObjectSearcher 时 - 可以搜索特定属性(而不是通过 *
搜索所有属性)。
实例化ManagementClass(即new ManagementClass(someClass)
)时会发生什么,它加载所有属性,还是只是某种指针,不会加载属性?
.
(我也很高兴知道将 ManagementObjectSearcher
与 *
一起使用时会发生什么,它会加载属性以外的任何内容,还是就像指定所有这些都是明确的吗?从逻辑上讲,它应该只是表示 "all",但从 here 看来并非如此。)
实例化它时没有任何反应。它只是 stores the query, scope and whatever else you may have specified。 ManagementObjectSearcher
当您调用 .Get()
、the query is executed against the current scope. As for ManagementObjectSearcher
, the actual behavior depends on whether it's a class enumeration or instance enumeration (e.g. a query)
执行查询并直接获得 return 结果(任何属性),而 class 枚举将绑定到基础 WMI 对象 without actually loading anything,直到您调用 .Get()
某处。
does it load all of the properties, or is it only some sort of pointer
它是一个 pointer to the CIM Object Manager. The underlying objects are only loaded when initialize is called with true(表示您要绑定到基础 WMI 对象)。这是执行查询的对象。
查看对 Initialize()
的各种调用,乍一看似乎只有在您请求属性或限定符时才绑定对象。调用方法不会绑定它们。
I'd also be happy to know what happens when using ManagementObjectSearcher with a *
在您执行查询之前什么都没有。默认情况下,对对象执行 shallow enumeration。除了属性之外,这可能 return 限定符,但我对此并不完全确定。
也很有趣(包括兄弟文章):https://technet.microsoft.com/en-us/library/cc180561.aspx
我希望这对您有所帮助:)