更新:2007 年 11 月
定义关闭回调对象必须实现的方法。
IAgentTransportShutdownCallback : public IUnknown
方法
方法 |
说明 |
---|---|
为设备端代理提供执行清理和退出的机会。 |
备注
只要设备上正在运行 conmanclient2.exe,设备代理就非常有用。当 conmanclient2.exe 关闭时,所有的设备代理也将关闭。设备代理可以请求接收关闭通知,以便正常执行清理和退出操作。为了接收关闭通知,设备代理必须定义实现此接口的类并使用 IDeviceAgentTransport::RegisterShutdownCallback 注册该类。
示例
下面的示例定义此接口的一个自定义实现。有关完整的示例,请参见IDeviceAgentTransport。
// Custom implementation of IAgentTransportShutdownCallback
class MyShutdownCallback: public IAgentTransportShutdownCallback
{
private:
long ref;
public:
HRESULT STDMETHODCALLTYPE Shutdown(IUnknown *in_pUnknown)
{
// Add your cleanup code here
MessageBox(NULL,_T("conmanclient2 exited"),_T("conmanclient exited"),0);
return 0;
}
// Must implement members from IUnknown
HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
{
return 0;
}
ULONG STDMETHODCALLTYPE AddRef( void)
{
return InterlockedIncrement(&ref);
}
ULONG STDMETHODCALLTYPE Release( void)
{
if(InterlockedDecrement(&ref) == 0)
{
delete this;
return 0;
}
return ref;
}
};
托管等效项
Microsoft.SmartDevice.DeviceAgentTransport.IAgentTransportShutdownCallback
要求
DeviceAgentTransport.h