Microsoft KB Archive/321381

= SAMPLE: Using ISensNetwork (SensNetDemo.exe) =

Article ID: 321381

Article Last Modified on 2/1/2007

-

APPLIES TO


 * Microsoft Windows XP Professional
 * Microsoft Windows XP Home Edition
 * Microsoft Windows 2000 Standard Edition
 * Microsoft Windows NT Server 4.0 Standard Edition
 * Microsoft Windows NT 4.0 Service Pack 6a
 * Microsoft Windows NT Workstation 4.0 Developer Edition
 * Microsoft Windows NT Workstation 4.0 Developer Edition
 * Microsoft Windows Millennium Edition
 * Microsoft Windows 98 Second Edition
 * Microsoft Windows 98 Standard Edition
 * Microsoft Windows 95

-



This article was previously published under Q321381



SUMMARY
System Event Notification Service (SENS), a subset of Synchronization Manager, is designed for use by mobile users who require a unique set of connectivity functions. These functions allow programs to catch certain events and trigger later program-specific synchronization activities.

SENS supports the following four interfaces:
 * ISensLogon
 * ISensLogon2
 * ISensOnNow
 * ISensNetwork - This article contains a sample that demonstrates the use of this interface.

ISensNetwork is supported on the following operating systems:
 * Windows 2000 and later.
 * Windows Millennium Edition.
 * Windows NT 4.0 and Windows 95/98 require the use of Internet Explorer 5 or later.



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

Download SensNetDemo.exe now

Release Date: July 2, 2002

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Steps To Create the Sample

 * 1) Use ATL COM AppWizard to create a new Microsoft Visual C++ 6.0 project named SensNetDemo, and then click OK.
 * 2) For purposes of the demonstration, click Executable (EXE) as the server type, and then click Finish.
 * 3) In the New Project Information dialog box, click OK.
 * 4) In ClassView, right-click SensNetDemo classes, and then click New ATL Object.
 * 5) In ATL Object Wizard, click Simple Object, and then click Next.
 * 6) Type a short name, for example MySensNet, and then click OK.
 * 7) Expand SensNetDemo classes, right-click CMySensNet, and then click Implement Interface. Click OK to close the Warning dialog box.
 * 8) In the Browse Type Libraries dialog box, click SENS Events Type Library, and then click OK.
 * 9) Select ISensNetwork, and then click OK.
 * 10) Click FileView, add a new header file named mysens.h. Include SensApi.h, Sens.h, and EventSys.h. The header file also contains additional definitions.
 * 11) Open SensNetDemo.cpp and include mysens.h.

The main code is complete, to which you can add the custom code. See sample for details.

Additional Considerations
Consider the following when you use ISensNetwork:
 * To make sure that ISensNetwork works on all supported platforms, you must subscribe each event individually by using a unique GUID and a separate IEventSubscription object.
 * Notifications - WAN vs. LAN
 * For WAN (RAS or VPN) Connect/Disconnect, notifications are almost instantaneous.
 * For LAN Connect/Disconnect, notifications may be delayed for 3 to 5 minutes. Because SENS is intended for mobile users, Microsoft recommends that you consider other functions for LANs, such as the WMI Win32_NetworkAdapter class, the IP Helper GetAdaptersInfo function, or the Winsock 2 WSAIoctl function (SIO_ADDRESS_LIST_CHANGE/QUERY).

