Background
People who have used Windows Mobile probably have the experience of connecting a mobile phone to a PC using USB cable. This is generally done by ActiveSync. ActiveSync in Windows Embedded ce andWindows Mobile and PC play an important role in interoperability. With ActiveSync, PC can check Windows Embedded ce.AndThe hardware, operating system, memory, and other version information of Windows Mobile devices access and modify the registry, add, delete, modify, and transfer files, and even call the DLL of the device. This article describes the development of ActiveSync.
What is ActiveSync?
ActiveSync is a data synchronization developed by Microsoft.ProgramEnables the PC to synchronize documents, emails, calendar schedules, and contact lists on Windows Embedded ce, Windows Mobile, and other devices. In addition, ActiveSync provides manual File Transfer and synchronization functions to install and uninstall programs on Windows Embedded ce and Windows Mobile devices on a PC. After Vista, ActiveSync was banned by Windows Mobile Device Center.
What is rndis?
Rndis (Remote NDIS) is another common specification for connecting Windows Embedded ce devices and PCs through USB.
Remote NDIS drivers for USB
Chart from http://www.microsoft.com/whdc/device/network/ndis/rmndis.mspx
From the developer's point of view, rndis can be understood as IP over USB. After C and Windows Embedded CE are linked, an IP address will be assigned and can be developed based on this IP network. Rndis is widely used in USB devices. For example, ADSL devices generally support rndis, so that you can configure the device by connecting to USB.
Download
ActiveSync can only be used for XP. The current version is 4.5. The download link is as follows: Download Microsoft ActiveSync 4.5
If you use Vista, use Windows Mobile Device Center. The current version is 6.1. The download link is as follows: Download Windows Mobile Device Center 6.1
For the development of ActiveSync, I used the opennetcf desktop communication library, which is an open source Library Based on the MIT license (MIT. Download from the following link. Http://rapi.codeplex.com/Release/ProjectReleases.aspx? Releaseid = 29281
Interface
The functions of ActiveSync are encapsulated in the ActiveSync class of the opennetcf desktop communication library.
Method
The ActiveSync class connects the device through connectnow () and disconnectnow (), and disconnects the device.
Rapi. ActiveSync. connectnow ();
Rapi. ActiveSync. showcommsettings ();
Rapi. ActiveSync. disconnectnow ();
Showcommsettings () shows the current device connection status.
Attribute
When the device is connected or disconnected, you can configure an Automatic startup program.
Rapi. ActiveSync. autoconnect =True;
Rapi. ActiveSync. autostartonconnect. Add (@ "C: \ WINDOWS \ notepad.exe");
Rapi. ActiveSync. autostartondisconnect. Add (@ "C: \ WINDOWS \ regedit.exe");
Set the property autoconnect to true. When the device is connected, ActiveSync automatically links. Set autostartonconnect and autostartondisconnect. When the connection is closed or closed, the configured program is automatically started.
Event
Subscribe to active and disconnect events to process the link status change messages.
Rapi. ActiveSync. Active + =NewActivehandler(Activesync_active );
Rapi. ActiveSync. Disconnect + =NewDisconnecthandler(Activesync_disconnect );
VoidActivesync_disconnect ()
{
Labelactivesync. Text ="Device disconnected";
}
VoidActivesync_active ()
{
Labelactivesync. Text ="Device connected";
}
Here, it is very simple. The next article will introduce rapi.