COM实现系统SENS接口获取网络断开事件

本文详细介绍了ISensNetworkInterface接口及其在Windows系统中的应用,如何通过ATL类实现事件订阅,并解析了各个事件方法的用途。此外,还提供了一个包含事件订阅实例的源代码段落。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ISensNetwork Interface


从MSDN拷贝的关于ISensNetwork说明。查看实现源码

The ISensNetwork interface handles network events fired by the System Event Notification Service (SENS).

When To Implement

Implement this interface on your sink object if you subscribe to any of the SENS network events. Each event corresponds to a method in this interface. This interface is an outgoing interface defined by SENS and implemented by the subscriber application as a dispatch interface.

When To Use

SENS and the COM Event System call the ISensNetwork methods on your sink object to fire the corresponding event.

Starting with applications designed for Windows Vista and Windows Server 2008, developers should consider using the Network List Manager instead of this interface.

Methods

The ISensNetwork interface inherits the methods of the IDispatch interface.

In addition, ISensNetwork defines the following methods.

MethodDescription

ConnectionMade

Specified connection has been established.

ConnectionMadeNoQOCInfo

Specified connection has been established with no Quality of Connection information available.

ConnectionLost

Specified connection has been dropped.

 

Windows中系统提供了System Event Notification Service(SENS),系统事件通告服务。

我们用它可以得到:

  • TCP/IP网络事件,例如TCP/IP网络连接状态或连接质量信息。
  • 用户登入事件。
  • 电池和电源事件。

使用VC向导增加一个ATL类,

在头文件中导入Sens.dll。VC会自动生成头文件,包括Sens接口的定义。

 

// SensNetEvents.h : Declaration of the CSensNetEvents

#pragma once

#include "resource.h"       // main symbols
#include "StockInfo_i.h"
#import "C:\WINDOWS\System32\SENS.DLL" raw_interfaces_only, raw_native_types, no_namespace, named_guids 


#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif

// CSensNetEvents

class ATL_NO_VTABLE CSensNetEvents :
  public CComObjectRootEx<CComSingleThreadModel>,
  public CComCoClass<CSensNetEvents, &CLSID_SensNetEvents>,
  public IDispatchImpl<ISensNetEvents, &IID_ISensNetEvents, &LIBID_StockInfoLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
  public IDispatchImpl<ISensOnNow, &IID_ISensOnNow, &LIBID_SensEvents>,
  public IDispatchImpl<ISensLogon, &IID_ISensLogon, &LIBID_SensEvents>,
  public IDispatchImpl<ISensLogon2, &IID_ISensLogon2, &LIBID_SensEvents>,
  public IDispatchImpl<ISensNetwork, &IID_ISensNetwork, &LIBID_SensEvents>
{
public:
  CSensNetEvents();

  HRESULT FinalConstruct();
  void FinalRelease();

DECLARE_PROTECT_FINAL_CONSTRUCT()
DECLARE_REGISTRY_RESOURCEID(IDR_SENSNETEVENTS)

BEGIN_COM_MAP(CSensNetEvents)
  COM_INTERFACE_ENTRY(ISensOnNow)
  COM_INTERFACE_ENTRY(ISensLogon)
  COM_INTERFACE_ENTRY(ISensLogon2)
  COM_INTERFACE_ENTRY(ISensNetwork)
  COM_INTERFACE_ENTRY(ISensNetEvents)
  COM_INTERFACE_ENTRY2(IDispatch, ISensNetEvents)
END_COM_MAP()

// ISensNetEvents property
public:
  STDMETHOD (get_OwnerWindow)(OLE_HANDLE* pVal);
  STDMETHOD (put_OwnerWindow)(OLE_HANDLE newVal);

// ISensNetEvents methods
public:
  STDMETHOD (StartMonitor)(OLE_HANDLE hWnd);
  STDMETHOD (StopMonitor)(void);

public:
  // ISensNetwork
  STDMETHOD (ConnectionMade)(BSTR, unsigned long, struct SENS_QOCINFO *);
  STDMETHOD (ConnectionMadeNoQOCInfo)(BSTR, unsigned long);
  STDMETHOD (ConnectionLost)(BSTR, unsigned long);
  STDMETHOD (DestinationReachable)(BSTR,BSTR, unsigned long, struct SENS_QOCINFO *);
  STDMETHOD (DestinationReachableNoQOCInfo)(BSTR, BSTR, unsigned long);

public:
  // ISensOnNow
  STDMETHOD (OnACPower)();
  STDMETHOD (OnBatteryPower)(unsigned long);
  STDMETHOD (BatteryLow)(unsigned long);
  
public:
  // ISensLogon
  STDMETHOD (Logon)(BSTR);
  STDMETHOD (Logoff)(BSTR);
  STDMETHOD (StartShell)(BSTR);
  STDMETHOD (DisplayLock)(BSTR);
  STDMETHOD (DisplayUnlock)(BSTR);
  STDMETHOD (StartScreenSaver)(BSTR);
  STDMETHOD (StopScreenSaver)(BSTR);
  
public:
  // ISensLogon2
  STDMETHOD (Logon)(BSTR, unsigned long);
  STDMETHOD (Logoff)(BSTR, unsigned long);
  STDMETHOD (SessionDisconnect)(BSTR, unsigned long);
  STDMETHOD (SessionReconnect)(BSTR, unsigned long);
  STDMETHOD (PostShell)(BSTR, unsigned long);

private:
  HWND m_hOwnerWnd;
  CComPtr<IEventSystem> m_EventSys;

};

typedef struct tagSensNetSubscribe
{
  const GUID Id;
  LPCSTR Name;
  LPCSTR Method;
  const GUID classId;
} SENSNET_SUBSCRIBE, *PSENSNET_SUBSCRIBE;

extern const __declspec(selectany) SENSNET_SUBSCRIBE SensNet_Subscribe_Array[] =
{
  // ---------------------------------ISensNetwork ---------------------------------
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x00 } },
    "ISensNetwork::ConnectionMade",
    "ConnectionMade",
    { 0xd5978620, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x01 } },
    "ISensNetwork::ConnectionMadeNoQOCInfo",
    "ConnectionMadeNoQOCInfo",
    { 0xd5978620, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x02 } },
    "ISensNetwork::ConnectionLost",
    "ConnectionLost",
    { 0xd5978620, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x03 } },
    "ISensNetwork::DestinationReachable",
    "DestinationReachable",
    { 0xd5978620, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x04 } },
    "ISensNetwork::DestinationReachableNoQOCInfo",
    "DestinationReachableNoQOCInfo",
    { 0xd5978620, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },

  // -----------------------------------ISensOnNow -----------------------------------
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x05 } },
    "ISensOnNow::OnACPower",
    "OnACPower",
    { 0xd5978640, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x06 } },
    "ISensOnNow::OnBatteryPower",
    "OnBatteryPower",
    { 0xd5978640, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x07 } },
    "ISensOnNow::BatteryLow",
    "BatteryLow",
    { 0xd5978640, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  
  // -----------------------------------ISensLogon-----------------------------------
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x08 } },
    "ISensLogon::Logon",
    "Logon",
    { 0xd5978630, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x09 } },
    "ISensLogon::Logoff",
    "Logoff",
    { 0xd5978630, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x0a } },
    "ISensLogon::StartShell",
    "StartShell",
    { 0xd5978630, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x0b } },
    "ISensLogon::DisplayLock",
    "DisplayLock",
    { 0xd5978630, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x0c } },
    "ISensLogon::DisplayUnlock",
    "DisplayUnlock",
    { 0xd5978630, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x0d } },
    "ISensLogon::StartScreenSaver",
    "StartScreenSaver",
    { 0xd5978630, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x0e } },
    "ISensLogon::StopScreenSaver",
    "StopScreenSaver",
    { 0xd5978630, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },

  // -----------------------------------ISensLogon2-----------------------------------
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x0f } },
    "ISensLogon2::Logon",
    "Logon",
    { 0xd5978650, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x10 } },
    "ISensLogon2::Logoff",
    "Logoff",
    { 0xd5978650, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x11 } },
    "ISensLogon2::SessionDisconnect",
    "SessionDisconnect",
    { 0xd5978650, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x12 } },
    "ISensLogon2::SessionReconnect",
    "SessionReconnect",
    { 0xd5978650, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
  {
    { 0x7bf4904f, 0xf525, 0x4173, { 0xb6, 0x10, 0x24, 0x6e, 0x1, 0x99, 0x1a, 0x13 } },
    "ISensLogon2::PostShell",
    "PostShell",
    { 0xd5978650, 0x5b9f, 0x11d1, { 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e} }
  },
};

#define SUBSCRIBE_COUNT (sizeof(SensNet_Subscribe_Array) / sizeof(SENSNET_SUBSCRIBE))

OBJECT_ENTRY_AUTO(__uuidof(SensNetEvents), CSensNetEvents)


 

源文件:

#include "stdafx.h"
#include "SensNetEvents.h"

//IEventSystem* pEventSys = NULL;

CSensNetEvents::CSensNetEvents():
  m_hOwnerWnd(NULL),
  m_EventSys(NULL)
{
  ATLTRACE("CSensNetEvents::CSensNetEvents");

}

HRESULT CSensNetEvents::FinalConstruct()
{
  ATLTRACE("CSensNetEvents::FinalConstruct");

  StopMonitor();

  return S_OK;
}

void CSensNetEvents::FinalRelease()
{
  ATLTRACE("CSensNetEvents::FinalRelease");

}

STDMETHODIMP CSensNetEvents::ConnectionMade(
    BSTR bstrConnection, 
    ULONG ulType, 
    SENS_QOCINFO * lpQOCInfo)
{
  ATLTRACE("CSensNetEvents::ConnectionMade");
  
  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::ConnectionMadeNoQOCInfo(
    BSTR bstrConnection, 
    ULONG ulType)
{
  ATLTRACE("CSensNetEvents::ConnectionMadeNoQOCInfo");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::ConnectionLost(
    BSTR bstrConnection, 
    ULONG ulType)
{
  ATLTRACE("CSensNetEvents::ConnectionLost");
  
  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::DestinationReachable(
    BSTR bstrDestination, 
    BSTR bstrConnection, 
    ULONG ulType, 
    SENS_QOCINFO * lpQOCInfo)
{
  ATLTRACE("CSensNetEvents::DestinationReachable");
  
  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::DestinationReachableNoQOCInfo(
    BSTR bstrDestination, 
    BSTR bstrConnection, 
    ULONG ulType)
{
  ATLTRACE("CSensNetEvents::DestinationReachableNoQOCInfo");
  
  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::Logon(
    BSTR bstrUserName)
{
  ATLTRACE("CSensNetEvents::Logon");
  
  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::Logoff(
    BSTR bstrUserName)
{
  ATLTRACE("CSensNetEvents::Logoff");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::StartShell(
    BSTR bstrUserName)
{
  ATLTRACE("CSensNetEvents::StartShell");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::DisplayLock(
    BSTR bstrUserName)
{
  ATLTRACE("CSensNetEvents::DisplayLock");
  
  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::DisplayUnlock(
    BSTR bstrUserName)
{
  ATLTRACE("CSensNetEvents::DisplayUnlock");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::StartScreenSaver(
    BSTR bstrUserName)
{
  ATLTRACE("CSensNetEvents::StartScreenSaver");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::StopScreenSaver(
    BSTR bstrUserName)
{
  ATLTRACE("CSensNetEvents::StopScreenSaver");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::OnACPower()
{
  ATLTRACE("CSensNetEvents::OnACPower");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::OnBatteryPower(
    unsigned long dwBatteryLifePercent)
{
  ATLTRACE("CSensNetEvents::OnBatteryPower");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::BatteryLow(
    unsigned long dwBatteryLifePercent)
{
  ATLTRACE("CSensNetEvents::BatteryLow");

  return E_NOTIMPL;
}


STDMETHODIMP CSensNetEvents::Logon(
    BSTR bstrUserName,
    unsigned long dwSessionId)
{
  ATLTRACE("CSensNetEvents::Logon");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::Logoff(
    BSTR bstrUserName,
    unsigned long dwSessionId)
{
  ATLTRACE("CSensNetEvents::Logoff");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::SessionDisconnect(
    BSTR bstrUserName,
    unsigned long dwSessionId)
{
  ATLTRACE("CSensNetEvents::SessionDisconnect");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::SessionReconnect(
    BSTR bstrUserName,
    unsigned long dwSessionId)
{
  ATLTRACE("CSensNetEvents::SessionReconnect");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::PostShell(
    BSTR bstrUserName,
    unsigned long dwSessionId)
{
  ATLTRACE("CSensNetEvents::PostShell");

  return E_NOTIMPL;
}

STDMETHODIMP CSensNetEvents::get_OwnerWindow(OLE_HANDLE* pVal)
{
  AFX_MANAGE_STATE(AfxGetStaticModuleState());

  // TODO: Add your implementation code here
  *pVal = (OLE_HANDLE)m_hOwnerWnd;

  return S_OK;
}

STDMETHODIMP CSensNetEvents::put_OwnerWindow(OLE_HANDLE newVal)
{
  AFX_MANAGE_STATE(AfxGetStaticModuleState());

  // TODO: Add your implementation code here
  m_hOwnerWnd = (HWND)newVal;

  return S_OK;
}

STDMETHODIMP CSensNetEvents::StartMonitor(OLE_HANDLE hWnd)
{
  AFX_MANAGE_STATE(AfxGetStaticModuleState());

  ATLTRACE("CSensNetEvents::StartMonitor -- Begin");

  DWORD dwFlags = 0;
  ::IsNetworkAlive((LPDWORD)&dwFlags);

  m_hOwnerWnd = (HWND)hWnd;

  if ( !m_EventSys )
  {
    if ( FAILED(m_EventSys.CoCreateInstance(CLSID_CEventSystem, NULL, CLSCTX_SERVER)) )
    {
      ATLTRACE("FAILED: CSensNetEvents::StartMonitor m_EventSys->CoCreateInstance");
      return E_FAIL;
    }
    ATLTRACE("SUCCEED: CSensNetEvents::StartMonitor m_EventSys->CoCreateInstance");
  }

  int failed = 0;

  for (int i = 0; i < SUBSCRIBE_COUNT; i++, failed++ )
  {
    CComPtr<IEventSubscription> pSubscription;

    if ( FAILED(pSubscription.CoCreateInstance(CLSID_CEventSubscription)) )
    {
      ATLTRACE("FAILED: CSensNetEvents::StartMonitor pSubscription->CoCreateInstance");
      continue;
    }
    
    pSubscription->put_SubscriptionID(CComBSTR(SensNet_Subscribe_Array[i].Id));
    pSubscription->put_EventClassID(CComBSTR(SensNet_Subscribe_Array[i].classId));
    pSubscription->put_SubscriptionName(CComBSTR(SensNet_Subscribe_Array[i].Name));
    pSubscription->put_MethodName(CComBSTR(SensNet_Subscribe_Array[i].Method));
    pSubscription->put_SubscriberInterface((ISensNetEvents*)this);
    pSubscription->put_Enabled(TRUE);

    if ( FAILED(m_EventSys->Store(CComBSTR(PROGID_EventSubscription), pSubscription)) )
    {
      ATLTRACE("FAILED: CSensNetEvents::StartMonitor EventSys->Store");
    }
    else
    {
      ATLTRACE("SUCCEED: CSensNetEvents::StartMonitor EventSys->Store");
      failed--;
    }
  }

  ATLTRACE("CSensNetEvents::StartMonitor -- Completed");

  return failed > 0 ? E_FAIL : S_OK;
}

STDMETHODIMP CSensNetEvents::StopMonitor(void)
{
  AFX_MANAGE_STATE(AfxGetStaticModuleState());

  ATLTRACE("CSensNetEvents::StopMonitor -- Begin");

  if ( !m_EventSys )
  {
    //if ( FAILED(m_EventSys.CoCreateInstance(CLSID_CEventSystem, NULL, CLSCTX_SERVER)) )
    //{
      ATLTRACE("FAILED: CSensNetEvents::StopMonitor m_EventSys->CoCreateInstance");
      return E_FAIL;
    //}
    //ATLTRACE("SUCCEED: CSensNetEvents::StopMonitor m_EventSys->CoCreateInstance");
  }

  int failed = 0;

  for (int i = 0; i < SUBSCRIBE_COUNT; i++)
  {
    CComBSTR bsQuery(TEXT("SubscriptionID="));
    int err;

    bsQuery += CComBSTR(SensNet_Subscribe_Array[i].Id);

    if ( FAILED(m_EventSys->Remove(PROGID_EventSubscription, bsQuery, &err)) )
    {
      ATLTRACE("FAILED: CSensNetEvents::StopMonitor m_EventSys->Remove");
      failed++;
    }
    else
    {
      ATLTRACE("SUCCEED: CSensNetEvents::StopMonitor m_EventSys->Remove");
    }
  }

  ATLTRACE("CSensNetEvents::StopMonitor -- Completed");

  return failed > 0 ? E_FAIL : S_OK;
}


COM注册表注册文件:

HKCR
{
	StockInfo.SensNetEvents.1 = s 'SensNetEvents Class'
	{
		CLSID = s '{0DCC8034-7433-456F-9200-0BF9F3EFBD1F}'
	}
	StockInfo.SensNetEvents = s 'SensNetEvents Class'
	{
		CLSID = s '{0DCC8034-7433-456F-9200-0BF9F3EFBD1F}'
		CurVer = s 'StockInfo.SensNetEvents.1'
	}
	NoRemove CLSID
	{
		ForceRemove {0DCC8034-7433-456F-9200-0BF9F3EFBD1F} = s 'SensNetEvents Class'
		{
			ProgID = s 'StockInfo.SensNetEvents.1'
			VersionIndependentProgID = s 'StockInfo.SensNetEvents'
			ForceRemove 'Programmable'
			InprocServer32 = s '%MODULE%'
			{
				val ThreadingModel = s 'Apartment'
			}
			'TypeLib' = s '{7204EEE7-A379-4A28-93D4-F33151DDECD8}'
		}
	}
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值