Arkady
Wed Jul 06 02:11:13 CDT 2005
Additionally : look at
http://www.ndis.com/faq/QA01050301/default.htm
Arkady
"Pavel A." <pavel_a@NOwritemeNO.com> wrote in message
news:54736230-D8F1-415D-9D52-D66F637EF32C@microsoft.com...
> "Niklas" wrote:
>> Hello,
>> What is the best way to know if the adapter changes state from
>> disconncted
>> to enabled?
>
> In user mode: WMI.
> The sample below is vbscript. Same can be done in C++, .NET and so on.
>
> In kernel mode, protocols just receive indications from their bound
> miniports.
>
> ' ------------ cut here ----------------------------------
> ' ***** Receive media connect and disconnect events
> Set objWMIServices=
> GetObject("winmgmts:{impersonationLevel=impersonate}!root/wmi")
> set objSink = WScript.CreateObject("WbemScripting.SWbemSink","SINK1_")
> set objSink2 = WScript.CreateObject("WbemScripting.SWbemSink","SINK2_")
>
> objWMIServices.ExecNotificationQueryAsync objSink, "Select * from
> MSNdis_StatusMediaConnect"
> objWMIServices.ExecNotificationQueryAsync objSink2, "Select * from
> MSNdis_StatusMediaDisconnect"
>
> WScript.Echo "Waiting for Media_connect events..." & vbCrLf
>
> While(1)
> WScript.Sleep 1000
> ' or do something useful
> Wend
>
> '------- end main ------
>
> Sub SINK1_OnObjectReady(wmiObject, wmiAsyncContext)
> WScript.Echo "CONNECT event:" & vbCrLf & wmiObject.GetObjectText_()
> End Sub
>
> Sub SINK2_OnObjectReady(wmiObject, wmiAsyncContext)
> WScript.Echo "DISCONNECT event:" & vbCrLf & wmiObject.GetObjectText_()
> End Sub
>
> ' '-------------- cut here -----------
>
> The above vbscript is a modified sample by Calvin Guan (thanks :)
>
> --PA
>
>