다음을 통해 공유


winrt::Windows::Foundation::IUnknown 구조체(C++/WinRT)

Every C++/WinRT runtime class (whether a Windows or a third party runtime class) derives from winrt::Windows::Foundation::IUnknown. It represents the COM IUnknown interface, and it provides facilities such as querying for a different interface, abi functions, and comparison operators.

Syntax

struct IUnknown

Requirements

지원되는 최소 SDK: Windows SDK 버전 10.0.17134.0(Windows 10 버전 1803)

Namespace: winrt

Header: %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)

Constructors

Constructor Description
IUnknown::IUnknown constructor Initializes a new instance of the IUnknown struct, optionally with a copy or move of the input data.

Member functions

Function Description
IUnknown::as function 지원되지 않는 경우 throw하여 인터페이스를 요청합니다.
IUnknown::try_as function 인터페이스를 요청하여 null 지원되지 않는 경우 생성합니다.
IUnknown::try_as_with_reason function 지원되지 않는 경우 이유를 보고하여 인터페이스를 요청합니다.

Member operators

Operator Description
IUnknown::operator bool Checks whether or not the IUnknown object is referencing an interface.
IUnknown::operator=(대입 연산자) Assigns a value to the IUnknown object.

Free functions

Function Description
attach_abi function Attaches an IUnknown object to a raw pointer that owns a reference to its target; an additional reference is not added.
copy_from_abi function Copies to an IUnknown object from another pointer. 현재 참조된 인터페이스 또는 개체에 대한 참조 수를 감소시키고, 원시 포인터 매개 변수를 복사하고, 이 매개 변수가 가리키는 인터페이스 또는 개체의 수명 관리를 시작합니다.
copy_to_abi function Copies to another pointer from an IUnknown object. 현재 참조된 인터페이스 또는 개체에 대한 참조 횟수를 증가시키고 해당 인터페이스 또는 개체의 메모리 주소를 매개 변수에 복사합니다.
detach_abi function Detaches from the raw IUnknown interface without decrementing the reference count, perhaps to return it to a caller.
get_abi function Returns the underlying raw IUnknown interface pointer should you need to pass it to a function.
get_unknown function A helper function that returns the address of the underlying raw IUnknown interface of an object of a projected type.
put_abi function Returns the address of the underlying raw IUnknown interface pointer as a pointer to a pointer to void; this function helps you call methods (such as COM methods) that return references as out parameters via a pointer to a pointer to void.
swap function Swaps the contents of the two IUnknown parameters so that they point at one another's target.

Free operators

Function Description
operator!=(같지 않음 연산자) 두 매개 변수가 서로 다른 대상을 참조하는지 여부를 나타내는 값을 반환합니다.
연산자< (보다 작음 연산자) 첫 번째 매개 변수의 대상이 두 번째 매개 변수의 대상보다 메모리에서 일찍 발생하는지 여부를 나타내는 값을 반환합니다.
operator<=(보다 작거나 같음 연산자) 첫 번째 매개 변수의 대상이 두 번째 매개 변수의 대상보다 이전 메모리에서 발생하는지 또는 동일한 위치에서 발생하는지 여부를 나타내는 값을 반환합니다.
operator==(같음 연산자) 두 매개 변수가 동일한 인터페이스 및/또는 개체를 참조하는지 여부를 나타내는 값을 반환합니다.
연산자> (보다 큼 연산자) 첫 번째 매개 변수의 대상이 두 번째 매개 변수의 대상보다 나중에 메모리에서 발생하는지 여부를 나타내는 값을 반환합니다.
operator>=(보다 크거나 같음 연산자) 첫 번째 매개 변수의 대상이 두 번째 매개 변수의 대상보다 나중에 메모리에서 발생하는지 또는 동일한 위치에서 발생하는지 여부를 나타내는 값을 반환합니다.

IUnknown::IUnknown constructor

Initializes a new instance of the IUnknown struct, optionally with a copy or move of the input data.

Syntax

IUnknown() noexcept;
IUnknown(std::nullptr_t) noexcept;
IUnknown(winrt::Windows::Foundation::IUnknown const& other) noexcept;
IUnknown(winrt::Windows::Foundation::IUnknown&& other) noexcept;

Parameters

other Another IUnknown that initializes the IUnknown object.

IUnknown::as function

에서 지정된 인터페이스를 IUnknown요청합니다. 인터페이스가 지원되지 않는 경우 throw합니다. 인터페이스가 지원될 것으로 예상되는 경우 이 메서드를 사용합니다.

Syntax

template <typename To> auto as() const;
template <typename To> void as(To& to) const;

Template parameters

typename To 요청된 인터페이스를 설명하는 형식입니다. 이 형식은 C++/WinRT 인터페이스 이름 또는 C++/WinRT 런타임 클래스 이름일 수 있습니다.

-returning 오버로드의 auto경우 형식은 클래식 COM 인터페이스일 수도 있습니다.

-returning 오버로드의 void경우 형식은 클래식 COM 인터페이스의 위치 Icom_ptr<I> 수도 있습니다.

Parameters

to 요청된 인터페이스를 수신하기 위한 값에 대한 참조입니다.

Return value

auto-returning 오버로드는 C++/WinRT 인터페이스 To 또는 런타임 클래스 이름인 경우 또는 클래식 COM 인터페이스인 경우 To 형식으로 com_ptr<To> 요청된 인터페이스를 반환합니다.

IUnknownnull경우 -returning 오버로드가 auto반환null되고 -returning 오버로드가 void.로 null설정됩니다to.

그렇지 IUnknownnull 만 인터페이스를 가져올 수 없는 경우 메서드가 throw됩니다.

IUnknown::try_as function

에서 지정된 인터페이스를 IUnknown요청합니다. 인터페이스가 null 지원되지 않는 경우 생성합니다.

Syntax

template <typename To> auto try_as() const noexcept;
template <typename To> bool try_as(To& to) const noexcept;

Template parameters

typename To 요청된 인터페이스를 설명하는 형식입니다. 이 형식은 C++/WinRT 인터페이스 이름 또는 C++/WinRT 런타임 클래스 이름일 수 있습니다.

-returning 오버로드의 auto경우 형식은 클래식 COM 인터페이스일 수도 있습니다.

-returning 오버로드의 bool경우 형식은 클래식 COM 인터페이스의 위치 Icom_ptr<I> 수도 있습니다.

Parameters

to 요청된 인터페이스를 수신하기 위한 값에 대한 참조입니다.

Return value

auto-returning 오버로드는 C++/WinRT 인터페이스 To 또는 런타임 클래스 이름인 경우 또는 클래식 COM 인터페이스인 경우 To 형식으로 com_ptr<To> 요청된 인터페이스를 반환합니다.

IUnknown null is 또는 인터페이스를 가져올 auto수 없는 경우 -returning 오버로드가 반환null되고 bool-returning 오버로드가 로 설정 tonull됩니다.

bool 반환되는 오버로드는 반환된 값이 아닌null 경우와 false 반환 to 되는 경우 반환 true 됩니다null.

IUnknown::try_as_with_reason function

지원되는 경우 요청된 인터페이스를 반환하고 지원되지 않는 경우 이유를 보고합니다.

Syntax

template <typename To> auto try_as_with_reason(winrt::hresult& reason) const noexcept;

Template parameters

typename To 요청된 인터페이스를 설명하는 형식입니다. 이 형식은 C++/WinRT 인터페이스 이름, C++/WinRT 런타임 클래스 이름 또는 클래식 COM 인터페이스일 수 있습니다.

Parameters

reason 쿼리 결과를 winrt::hresult 설명하는 값을 받습니다.

Return value

C++/WinRT 인터페이스 To 또는 런타임 클래스 이름인 경우 또는 클래식 COM 인터페이스인 경우 To 형식으로 com_ptr<To> 요청된 인터페이스를 반환합니다.

is IUnknownnull 또는 인터페이스를 가져올 수 없는 경우 메서드가 반환됩니다 null.

Remarks

이 메서드는 C++/WinRT 버전 2.0.250303.1부터 사용할 수 있습니다.

IUnknownnull경우 메서드가 반환 null 되고 다음을 reason 설정합니다 S_OK.

이 값이 IUnknown 아닌null 경우 메서드는 쿼리의 결과를 반환하고 reason 쿼리에서 생성된 결과를 받 winrt::hresult 습니다.

IUnknown::operator bool

Checks whether or not the IUnknown object is referencing an interface. If the IUnknown object is not referencing an interface, then it is logically null; otherwise it is logically not null.

Syntax

explicit operator bool() const noexcept;

Return value

true if the IUnknown object is referencing an interface (logically not null), otherwise false (logically null).

IUnknown::operator=(대입 연산자)

Assigns a value to the IUnknown object.

Syntax

winrt::Windows::Foundation::IUnknown& operator=(winrt::Windows::Foundation::IUnknown const& other) noexcept;
winrt::Windows::Foundation::IUnknown& operator=(winrt::Windows::Foundation::IUnknown&& other) noexcept;
winrt::Windows::Foundation::IUnknown& operator=(std::nullptr_t) noexcept;

Parameters

other An IUnknown value to assign to the IUnknown object, either by copy or by move.

Return value

A reference to the IUnknown object.

attach_abi function

Attaches an IUnknown object to a raw pointer that owns a reference to its target; an additional reference is not added. 필요한 경우 이 함수를 사용하여 참조를 병합할 수 있습니다.

Syntax

void attach_abi(winrt::Windows::Foundation::IUnknown& object, void* value) noexcept;

Parameters

object An IUnknown value to operate on.

value 대상에 대한 참조를 소유하는 원시 포인터입니다.

copy_from_abi function

Copies to an IUnknown object from another pointer. 현재 참조된 인터페이스 또는 개체에 대한 참조 수를 감소시키고, 원시 포인터 매개 변수를 복사하고, 이 매개 변수가 가리키는 인터페이스 또는 개체의 수명 관리를 시작합니다.

Syntax

void copy_from_abi(winrt::Windows::Foundation::IUnknown& object, void* value) noexcept;

Parameters

object An IUnknown value to operate on.

value A raw pointer to a target whose lifetime should be managed by the IUnknown object.

copy_to_abi function

Copies to another pointer from an IUnknown object. 현재 참조된 인터페이스 또는 개체에 대한 참조 횟수를 증가시키고 해당 인터페이스 또는 개체의 메모리 주소를 매개 변수에 복사합니다. This function lets you hand out a reference to the same interface without calling QueryInterface.

Syntax

void copy_to_abi(winrt::Windows::Foundation::IUnknown const& object, void*& value) noexcept;

Parameters

object An IUnknown value to operate on.

value A raw pointer reference; via which to copy the pointer to the IUnknown object's target.

detach_abi function

Detaches an IUnknown object from its raw IUnknown interface without decrementing the reference count, perhaps to return it to a caller.

Syntax

void* detach_abi(winrt::Windows::Foundation::IUnknown& object) noexcept;
void* detach_abi(winrt::Windows::Foundation::IUnknown&& object) noexcept;

Parameters

object An IUnknown value to operate on.

Return value

A pointer to the raw IUnknown interface referenced by the IUnknown object.

get_abi function

Returns the underlying raw IUnknown interface pointer should you need to pass it to a function. You may call AddRef, Release, or QueryInterface on the returned pointer.

Syntax

void* get_abi(winrt::Windows::Foundation::IUnknown const& object) noexcept;

Parameters

object An IUnknown value to operate on.

Return value

A pointer to the raw IUnknown interface referenced by the IUnknown object.

operator!= (같지 않음 연산자)

두 매개 변수가 서로 다른 대상을 참조하는지 여부를 나타내는 값을 반환합니다.

Syntax

bool operator!=(winrt::Windows::Foundation::IUnknown const& left, winrt::Windows::Foundation::IUnknown const& right) noexcept;

Parameters

left right An IUnknown value whose target's memory address to compare with that of the other parameter.

Return value

true 두 매개 변수가 서로 다른 대상을 가리키면 그렇지 않습니다 false.

연산자< (보다 작음 연산자)

첫 번째 매개 변수의 대상이 두 번째 매개 변수의 대상보다 메모리에서 일찍 발생하는지 여부를 나타내는 값을 반환합니다.

Syntax

bool operator<(winrt::Windows::Foundation::IUnknown const& left, winrt::Windows::Foundation::IUnknown const& right) noexcept;

Parameters

left right An IUnknown value whose target's memory address to compare with that of the other parameter.

Return value

true 첫 번째 매개변수의 대상 메모리 주소가 두 번째 매개변수의 메모리 주소보다 작으면 그렇지 않습니다 false.

operator<=(보다 작거나 같음 연산자)

첫 번째 매개 변수의 대상이 두 번째 매개 변수의 대상보다 이전 메모리에서 발생하는지 또는 동일한 위치에서 발생하는지 여부를 나타내는 값을 반환합니다.

Syntax

bool operator<=(winrt::Windows::Foundation::IUnknown const& left, winrt::Windows::Foundation::IUnknown const& right) noexcept;

Parameters

left right An IUnknown value whose target's memory address to compare with that of the other parameter.

Return value

true 첫 번째 매개변수의 대상 메모리 주소가 두 번째 매개변수의 메모리 주소보다 작거나 같으면 , 그렇지 않으면 false.

operator==(같음 연산자)

두 매개 변수가 동일한 인터페이스 및/또는 개체를 참조하는지 여부를 나타내는 값을 반환합니다.

Syntax

bool operator==(winrt::Windows::Foundation::IUnknown const& left, winrt::Windows::Foundation::IUnknown const& right) noexcept;

Parameters

left right An IUnknown value whose target's memory address to compare with that of the other parameter.

Return value

true 두 매개 변수가 동일한 대상을 가리키면 그렇지 않으면 false.

연산자> (보다 큼 연산자)

첫 번째 매개 변수의 대상이 두 번째 매개 변수의 대상보다 나중에 메모리에서 발생하는지 여부를 나타내는 값을 반환합니다.

Syntax

bool operator>(winrt::Windows::Foundation::IUnknown const& left, winrt::Windows::Foundation::IUnknown const& right) noexcept;

Parameters

left right An IUnknown value whose target's memory address to compare with that of the other parameter.

Return value

true 첫 번째 매개변수의 대상의 메모리 주소가 두 번째 매개변수의 메모리 주소보다 크면, 그렇지 않으면 false.

operator>=(보다 크거나 같음 연산자)

첫 번째 매개 변수의 대상이 두 번째 매개 변수의 대상보다 나중에 메모리에서 발생하는지 또는 동일한 위치에서 발생하는지 여부를 나타내는 값을 반환합니다.

Syntax

bool operator>=(winrt::Windows::Foundation::IUnknown const& left, winrt::Windows::Foundation::IUnknown const& right) noexcept;

Parameters

left right An IUnknown value whose target's memory address to compare with that of the other parameter.

Return value

true 첫 번째 매개변수의 대상의 메모리 주소가 두 번째 매개변수의 메모리 주소보다 크거나 같으면, 그렇지 않으면 false.

put_abi function

Returns the address of the underlying raw IUnknown interface pointer as a pointer to a pointer to void; this function helps you call methods (such as COM methods) that return references as out parameters via a pointer to a pointer to void.

Syntax

void** put_abi(winrt::Windows::Foundation::IUnknown& object) noexcept;

Parameters

object An IUnknown value to operate on.

Return value

The address of the underlying raw IUnknown interface pointer.

swap function

Swaps the contents of the two IUnknown parameters so that they point at one another's target.

Syntax

void swap(winrt::Windows::Foundation::IUnknown& left, winrt::Windows::Foundation::IUnknown& right) noexcept;

Parameters

left right An IUnknown value whose pointer to mutually swap with that of the other parameter.

See also