Remove LAN-Adapter
-
Hello ! Can anyone tell me how my software can recognize that the LAN-Adapter has been removed from the computer ? Thank you, Chris
See http://www.codeproject.com/internet/getmac.asp?df=100&forumid=2459&exp=0&select=47194#xx47194xx maybe it'll help.. Keep a list of mac addresses in memory and periodically check if the list is up to date
-
See http://www.codeproject.com/internet/getmac.asp?df=100&forumid=2459&exp=0&select=47194#xx47194xx maybe it'll help.. Keep a list of mac addresses in memory and periodically check if the list is up to date
-
I don' t know if the problem was clear. I don't want to remove the ethernet-card. I will remove the cable from the Adapter. In this case windows shows a tip text message in the right bottom corner. I thought that I can caught this windows message.
Check this /* * ndis_events - test program for receiving NdisMIndicateStatus() * events * Copyright (c) 2004, Jouni Malinen * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * Alternatively, this software may be distributed under the terms * of BSD license. * * See README and COPYING for more details. */ #define _WIN32_WINNT 0x0400 #include #include #include #include class CNdisSink; struct EVENT_HANDLER_MAP { const wchar_t* EventName; void (CNdisSink::*Handler)(IWbemClassObject *pObj); }; class CNdisSink : public IWbemObjectSink { public: CNdisSink(); ~CNdisSink(); // IUnknown members STDMETHOD(QueryInterface)(REFIID, LPVOID *); STDMETHOD_(ULONG, AddRef)(void); STDMETHOD_(ULONG, Release)(void); // IWbemObjectSink members STDMETHOD(Indicate)( long lObjectCount, IWbemClassObject **ppObjArray); STDMETHOD(SetStatus)( long lFlags, HRESULT hResult, BSTR strParam, IWbemClassObject *pObjParam); public: int RegisterAsyncNotification(IWbemServices *pSvc); private: void AdapterArrival(IWbemClassObject *pObj){} void AdapterRemoval(IWbemClassObject *pObj){} void ResetStart(IWbemClassObject *pObj){} void ResetEnd(IWbemClassObject *pObj){} void LinkSpeedChange(IWbemClassObject *pObj){} void MediaConnect(IWbemClassObject *pObj); void MediaDisconnect(IWbemClassObject *pObj); void MediaSpecific(IWbemClassObject *pObj); void ProtocolBind(IWbemClassObject *pObj){} void ProtocolUnbind(IWbemClassObject *pObj){} void DevicePowerOn(IWbemClassObject *pObj){} void DevicePowerOff(IWbemClassObject *pObj){} private: static EVENT_HANDLER_MAP s_EventHandlerMap[]; UINT m_cRef; }; EVENT_HANDLER_MAP CNdisSink::s_EventHandlerMap[] = { { L"MSNdis_NotifyAdapterArrival", &CNdisSink::AdapterArrival }, { L"MSNdis_NotifyAdapterRemoval", &CNdisSink::AdapterRemoval }, { L"MSNdis_StatusResetStart", &CNdisSink::ResetStart }, { L"MSNdis_StatusResetEnd", &CNdisSink::ResetEnd }, { L"MSNdis_StatusLinkSpeedChange", &CNdisSink::LinkSpeedChange }, { L"MSNdis_StatusMediaConnect", &CNdisSink::MediaConnect }, { L"MSNdis_StatusMediaDiscon
-
Check this /* * ndis_events - test program for receiving NdisMIndicateStatus() * events * Copyright (c) 2004, Jouni Malinen * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * Alternatively, this software may be distributed under the terms * of BSD license. * * See README and COPYING for more details. */ #define _WIN32_WINNT 0x0400 #include #include #include #include class CNdisSink; struct EVENT_HANDLER_MAP { const wchar_t* EventName; void (CNdisSink::*Handler)(IWbemClassObject *pObj); }; class CNdisSink : public IWbemObjectSink { public: CNdisSink(); ~CNdisSink(); // IUnknown members STDMETHOD(QueryInterface)(REFIID, LPVOID *); STDMETHOD_(ULONG, AddRef)(void); STDMETHOD_(ULONG, Release)(void); // IWbemObjectSink members STDMETHOD(Indicate)( long lObjectCount, IWbemClassObject **ppObjArray); STDMETHOD(SetStatus)( long lFlags, HRESULT hResult, BSTR strParam, IWbemClassObject *pObjParam); public: int RegisterAsyncNotification(IWbemServices *pSvc); private: void AdapterArrival(IWbemClassObject *pObj){} void AdapterRemoval(IWbemClassObject *pObj){} void ResetStart(IWbemClassObject *pObj){} void ResetEnd(IWbemClassObject *pObj){} void LinkSpeedChange(IWbemClassObject *pObj){} void MediaConnect(IWbemClassObject *pObj); void MediaDisconnect(IWbemClassObject *pObj); void MediaSpecific(IWbemClassObject *pObj); void ProtocolBind(IWbemClassObject *pObj){} void ProtocolUnbind(IWbemClassObject *pObj){} void DevicePowerOn(IWbemClassObject *pObj){} void DevicePowerOff(IWbemClassObject *pObj){} private: static EVENT_HANDLER_MAP s_EventHandlerMap[]; UINT m_cRef; }; EVENT_HANDLER_MAP CNdisSink::s_EventHandlerMap[] = { { L"MSNdis_NotifyAdapterArrival", &CNdisSink::AdapterArrival }, { L"MSNdis_NotifyAdapterRemoval", &CNdisSink::AdapterRemoval }, { L"MSNdis_StatusResetStart", &CNdisSink::ResetStart }, { L"MSNdis_StatusResetEnd", &CNdisSink::ResetEnd }, { L"MSNdis_StatusLinkSpeedChange", &CNdisSink::LinkSpeedChange }, { L"MSNdis_StatusMediaConnect", &CNdisSink::MediaConnect }, { L"MSNdis_StatusMediaDiscon