SWbemNamedValueSet 개체

SWbemNamedValueSet 개체는 SWbemNamedValue 개체의 컬렉션입니다. SWbemNamedValueSet의 메서드 및 속성은 WMI에 특정 호출을 제출할 때 공급자에게 더 많은 정보를 보내는 데 주로 사용됩니다. SWbemServices의 모든 호출과 SWbemObject의 일부 호출은 이 형식의 개체인 선택적 매개 변수를 사용합니다. 클라이언트는 SWbemNamedValueSet 개체에 정보를 추가하고 호출을 매개 변수 중 하나로 사용하여 SWbemNamedValueSet 개체를 보낼 수 있습니다. 이 개체는 VBScript CreateObject 호출로 만들 수 있습니다.

자세한 내용은 컬렉션 액세스를 참조하세요.

참고

중요 - WMI의 기초가 되는 균일한 액세스 모델을 중단할 수 있으므로 가능하면 이 메커니즘을 사용하지 마세요. 공급자가 이 메커니즘을 사용하는 경우 이 메커니즘을 최대한 적게 사용해야 합니다. 공급자가 요청에 응답하기 위해 매우 구체적인 컨텍스트 정보를 많이 요구하는 경우 이 정보를 제공하려면 모든 클라이언트를 코딩해야 합니다. 이 메커니즘을 사용하면 필요한 경우 이러한 공급자에 액세스할 수 있습니다.

SWbemNamedValueSet 개체는 SWbemNamedValue 요소의 컬렉션입니다. 이러한 항목은 SWbemNamedValueSet.Add 메서드를 사용하여 컬렉션에 추가됩니다. 또한 SWbemNamedValueSet.Remove 메서드를 사용하여 제거되고 SWbemNamedValueSet.Item 메서드를 사용하여 검색됩니다. 메서드에 액세스하여 동적 공급자에 필요한 컨텍스트 정보를 입력할 수 있습니다. SWbemServices 메서드 중 하나를 호출한 후 다른 호출에 SWbemNamedValueSet 개체를 다시 사용할 수 있습니다.

기본 공급자는 SWbemNamedValueSet 개체에 포함된 정보를 결정합니다. WMI는 정보를 사용하지 않고 공급자에게 전달하기만 합니다. 공급자는 서비스 요청에 필요한 컨텍스트 정보를 게시해야 합니다.

멤버

SWbemNamedValueSet 개체에는 다음과 같은 형식의 멤버가 있습니다.

메서드

SWbemNamedValueSet 개체에는 다음과 같은 메서드가 있습니다.

메서드 설명
추가 컬렉션에 SWbemNamedValue 개체를 추가합니다.
복제 SWbemNamedValueSet 컬렉션의 복사본을 만듭니다.
DeleteAll 컬렉션에서 모든 항목을 제거하여 SWbemNamedValueSet 개체를 비워 줍니다.
항목 컬렉션에서 SWbemNamedValue 개체를 검색합니다. 개체의 기본 메서드입니다.
제거 컬렉션에서 SWbemNamedValue 개체를 제거합니다.

속성

SWbemNamedValueSet 개체에는 다음과 같은 속성이 있습니다.

속성 액세스 유형 설명
개수
읽기 전용
컬렉션의 항목 수입니다.

예제

다음 VBScript 샘플에서는 명명된 값이 배열 형식인 경우 명명된 값 집합의 조작을 보여줍니다.

Set Context = CreateObject("WbemScripting.SWbemNamedValueSet")

On Error Resume Next

Context.Add "n1", Array (1, 2, 3)
str = "The initial value of n1 is {"
for x=LBound(Context("n1")) to UBound(Context("n1"))
 str = str & Context("n1")(x)
 if x <> UBound(Context("n1")) Then
  str = str & ", "
 End if
next
str = str & "}"
WScript.Echo str

WScript.Echo ""

' report the value of an element of the context value
v = Context("n1")
WScript.Echo "By indirection the first element of n1 has value:",v(0)

' report the value directly
WScript.Echo "By direct access the first element of n1 has value:", Context("n1")(0)

' set the value of a single named value element
Context("n1")(1) = 11 
WScript.Echo "After direct assignment the first element of n1 has value:", Context("n1")(1)

' set the value of a single named value element
Set v = Context("n1")
v(1) = 345
WScript.Echo "After indirect assignment the first element of n1 has value:", Context("n1")(1)

' set the value of an entire context value
Context("n1") = Array (5, 34, 178871)
WScript.Echo "After direct array assignment the first element of n1 has value:", Context("n1")(1)

str = "After direct assignment the entire value of n1 is {"
for x=LBound(Context("n1")) to UBound(Context("n1"))
 str = str & Context("n1")(x)
 if x <> UBound(Context("n1")) Then
  str = str & ", "
 End if
next
str = str & "}"
WScript.Echo str

if Err <> 0 Then
 WScript.Echo Err.Description
 Err.Clear
End if

다음 Perl 샘플에서는 명명된 값이 배열 형식인 경우 명명된 값 집합의 조작을 보여줍니다.

use strict;
use Win32::OLE;

my ( $Context, $str, $x, @v);

eval {$Context = new Win32::OLE 'WbemScripting.SWbemNamedValueSet'; };
unless($@)
{
 $Context->Add("n1", [1, 2, 3]);
 $str = "The initial value of n1 is {";
 for ($x = 0; $x < @{$Context->Item("n1")->{Value}}; $x++)
 {
  $str = $str.@{$Context->Item("n1")->{Value}}[$x];
  if ($x != (@{$Context->Item("n1")->{Value}}) - 1 )
  {
   $str = $str.", ";
  }
 }
 $str = $str."}";
 print $str,"\n\n";

 # report the value of an element of the context value
 @v = @{$Context->Item("n1")->{Value}};
 print "By indirection the first element of n1 has value:", $v[0], "\n";

 # report the value directly
 print "By direct access the first element of n1 has value:", @{$Context->Item("n1")->{Value}}[0], "\n";

 # set the value of a single named value element
 @{$Context->Item("n1")->{Value}}[1] = 11;
 print "After direct assignment the first element of n1 has value:", 
       @{$Context->Item("n1")->{Value}}[1], "\n";

 # set the value of a single named value element
 @v = @{$Context->Item("n1")->{Value}};
 $v[1] = 345;
 print "After indirect assignment the first element of n1 has value:", 
    @{$Context->Item("n1")->{Value}}[1], "\n";

 # set the value of an entire context value
 $Context->Item("n1")->{Value} = [5, 34, 178871];
 print "After direct array assignment the first element of n1 has value:", 
   @{$Context->Item("n1")->{Value}}[1], "\n";

 $str = "After direct assignment the entire value of n1 is {";
 for ($x = 0; $x < @{$Context->Item("n1")->{Value}}; $x++)
 {
  $str = $str.@{$Context->Item("n1")->{Value}}[$x];
  if ($x != (@{$Context->Item("n1")->{Value}}) - 1 )
  {
   $str = $str.", ";
  }
 }
 $str = $str."}";
 print $str,"\n";
}
else
{
 print STDERR Win32::OLE->LastError, "\n";
}

요구 사항

요구 사항
지원되는 최소 클라이언트
Windows Vista
지원되는 최소 서버
Windows Server 2008
헤더
Wbemdisp.h
유형 라이브러리
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemNamedValueSet
IID
IID_ISWbemNamedValueSet

추가 정보

스크립팅 API 개체