本文整理汇总了C++中EventCallback::_LocDEQueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ EventCallback::_LocDEQueryInterface方法的具体用法?C++ EventCallback::_LocDEQueryInterface怎么用?C++ EventCallback::_LocDEQueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventCallback
的用法示例。
在下文中一共展示了EventCallback::_LocDEQueryInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
/**
* Entry point routine.
*
* There's no argument needed for registration but to uninstall, specify the
* "-uninstall" parameter.
*
* This routine connects to the Google Desktop event publisher and establishes
* an event subscription. The subscription can by filtered to only deliver
* events that belong to a certain schema. To specify a schema, use the
* "-s" flag, immediately followed by the schema name.
* Example:
* console_events -sEmail
*
* Repeating the -s flag is supported.
*/
int _tmain(int argc, TCHAR* argv[]) {
ArgumentCheck args;
if (!args.Check(argc, argv)) {
args.PrintUsage();
return -1;
}
long cookie = 0;
HRESULT hr;
if (args.IsUninstall()) {
hr = UnregisterFromGDEventFramework();
if (SUCCEEDED(hr))
return 0;
} else {
hr = EnsureRegistered(&cookie);
}
if (FAILED(hr)) {
_tprintf(_T("Unable to %s with the Google Desktop event framework - 0x%08X\n%s\n"),
args.IsUninstall() ? _T("unregister") : _T("register"), hr, GDErrorToString(hr));
return hr;
}
ATLASSERT(cookie != 0);
//
// Create an instance of the Google Desktop Event Publisher
// and set up a subscription
//
CComPtr<IGoogleDesktopEventPublisher> publisher;
hr = publisher.CoCreateInstance(L"GoogleDesktop.EventPublisher.1");
// Our callback object that will receive notifications
EventCallback callback;
// Our subscription that controls how events are delivered to us
CComPtr<IGoogleDesktopEventSubscription> subscription;
if (SUCCEEDED(hr)) {
CComPtr<IUnknown> callback_identity;
// Use ATL's special QI method to get the identity IUnknown pointer
// of our callback object.
hr = callback._LocDEQueryInterface(IID_IUnknown,
reinterpret_cast<void**>(&callback_identity));
ATLASSERT(SUCCEEDED(hr) && "_LocDEQueryInterface");
//
// Now connect our callback object to the GD Event Framework
// by subscribing to events, then configure the subscription
// and eventually, turn on the event stream.
//
hr = publisher->Subscribe(cookie, callback_identity, &subscription);
if (SUCCEEDED(hr)) {
if (argc > 1) {
hr = args.SetUserSpecifiedSchemaFilters(subscription);
}
if (SUCCEEDED(hr)) {
// This turns on the event stream
hr = subscription->put_active(VARIANT_TRUE);
}
}
}
if (FAILED(hr)) {
_tprintf(_T("An error occured while connecting to the Google Desktop event framework - 0x%08X\n%s\n"),
hr, GDErrorToString(hr));
return hr;
}
_tprintf(_T("Event information will show up here. Press Ctrl+C to stop.\n"));
hr = ReceiveEvents();
// Now turn off the subscription and unsubscribe
ATLVERIFY(SUCCEEDED(subscription->put_active(VARIANT_FALSE)));
ATLVERIFY(SUCCEEDED(publisher->Unsubscribe(subscription)));
// Print out some information on our exit status
if (FAILED(hr)) {
_tprintf(_T("An error occured during processing of events - 0x%08X\n%s\n"),
hr, GDErrorToString(hr));
} else {
_tprintf(_T("Have a nice day!\n"));
//.........这里部分代码省略.........