📄 client.cpp
字号:
// Client.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
#import "..\DbServerAttEvent\_DbServerAttEvent.tlb" \
no_namespace named_guids embedded_idl
//CComModule _Module;
[ module(name="ClientModule") ];
[ event_receiver(com) ]
class CEventHandler {
public:
HRESULT HandleFinished()
{
MessageBox(0, "FinishedUpdating", "Event Received", 0);
return S_OK;
}
void HookEvent(IDbObject* pSource)
{
__hook(&_IDbObjectEvents::FinishedUpdating,
pSource, &CEventHandler::HandleFinished);
}
void UnhookEvent(IDbObject* pSource)
{
__unhook(&_IDbObjectEvents::FinishedUpdating,
pSource, &CEventHandler::HandleFinished);
}
};
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
// _Module.Init(NULL, GetModuleHandle(NULL));
try
{
IDbObjectPtr p(CLSID_CDbObject);
CEventHandler eh;
// eh.DispEventAdvise(p);
eh.HookEvent(p);
p->UpdateIndexes();
cout << "Doing something else while the object works";
for (int i = 0; i < 10; i++)
{
cout << ".";
Sleep(1000);
}
cout << endl;
eh.UnhookEvent(p);
// eh.DispEventUnadvise(p);
}
catch(_com_error& e)
{
cout << e.ErrorMessage();
}
// _Module.Term();
CoUninitialize();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -