winrt:: event_token 結構(C++/WinRT)winrt::event_token struct (C++/WinRT)

向事件註冊事件處理委派時傳回的權杖;可以用來撤銷相同委派的註冊。A token returned when registering an event-handling delegate with an event; can be used to revoke the registration of the same delegate. 如需處理事件和程式碼範例的詳細資訊,請參閱在/WinRT 中C++使用委派來處理事件For more info about handling events, and code examples, see Handle events by using delegates in C++/WinRT.

語法Syntax

struct event_token

需求Requirements

最低支援 SDK: Windows SDK 版本10.0.17134.0 (Windows 10,版本1803)Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)

命名空間: winrtNamespace: winrt

標頭% WindowsSdkDir% Include<WindowsTargetPlatformVersion > \cppwinrt\winrt\base.h (預設包含)Header %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)

資料成員Data members

函數Function 描述Description
event_token:: value 資料成員event_token::value data member 不透明的數值,唯一代表具有事件之委派的註冊。An opaque numeric value uniquely representing the registration of a delegate with an event.

成員運算子Member operators

運算子Operator 描述Description
event_token:: operator boolevent_token::operator bool 檢查event_token物件是否有效並已初始化。Checks whether or not the event_token object is valid and initialized.

免費運算子Free operators

運算子Operator 描述Description
operator = = (等號比較運算子)operator== (equality operator) 傳回值,指出兩個參數是否彼此相等。Returns a value indicating whether the two parameters are equal to one another.

event_token:: operator boolevent_token::operator bool

檢查event_token物件是否有效並已初始化。Checks whether or not the event_token object is valid and initialized.

語法Syntax

explicit operator bool() const noexcept;

傳回值Return value

true,如果event_token物件有效且已初始化(其 value 欄位的值不是零),則為,否則為 falsetrue if the event_token object is valid and initialized (the value of its value field is not zero), otherwise false.

event_token:: value 資料成員event_token::value data member

不透明的數值,唯一代表具有事件之委派的註冊。An opaque numeric value uniquely representing the registration of a delegate with an event.

語法Syntax

int64_t value{};

operator = = (等號比較運算子)operator== (equality operator)

傳回值,指出兩個參數是否彼此相等。Returns a value indicating whether the two parameters are equal to one another.

語法Syntax

inline bool operator==(winrt::event_token const& left, winrt::event_token const& right) noexcept;

參數Parameters

left right 要與另一個參數比較的event_token值。left right An event_token value to compare with the other parameter.

傳回值Return value

true 如果兩個參數相等,則為,否則為 falsetrue if the two parameters are equal to one another, otherwise false.

另請參閱See also