Once a wizard has been built, it can be used to help create a Visual C++ project that uses ICS to monitor folders. The following steps outline how to use each wizard to build a project.
NT Service ICS Agent Wizard
Open a workspace by creating a new one, or selecting an existing one with Visual C++ 6.0.
Add a project to the current workspace. You should see the new wizard as an available project to add. Select the wizard project to add it. The names appear in the project selector as "ICS Agent AppWizard (NT Service)".
The wizard starts by logging you on to a MAPI session. Select a profile that corresponds to an Exchange mailbox.
The wizard now presents a list of folders with which to monitor for changes with ICS. Select all desired folders.
The wizard now prompts you as to whether you would like to manual synchronization, continuous polling, or both. Select an option.
Once completed, the wizard sets up the new project, and creates the framework code that performs the ICS synchronization. The folder information is stored in a file called FOLDER_EIDS.sav.
Add your custom code to the appropriate files.
Build the new application in the standard way. After building the executable, copy the file FOLDER_EIDS.sav to the build directory, Debug or Release. This file contains the profile and folder information needed to start the application. This file must always be present in the same directory as the executable.
Register the service with the system by typing the following at a command prompt: [projectname.exe] -install. (-remove unregisters the service.) This step adds two sets of standard keys to the registry: HKLM\SYSTEM\CurrentControlSet\Services\ICS_[projectname] and HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Applications\ICS[projectname]Service. The first contains subkeys like "DisplayName" and "ImagePath" which contain as values the service display name and the path to the executable respectively. The key "[projectname]_Data" specifies where the required *.sav files are located. The current directory holding the executable is used to build these keys.
Start the service by opening the Services applet, updating the "Log on As" value from system account to an account that has access to the folders you selected when building the project. Select Start to start the service. The service will log status and errors encountered to the event log.
MFC ICS Agent Wizard
Open a workspace by creating a new one, or selecting an existing one with Visual C++ 6.0.
Add a project to the current workspace. You should see the new wizard as an available project to add. Select the wizard project to add it. The names appear in the project selector as "ICS Agent AppWizard (MFC exe)".
The wizard starts by logging you on to a MAPI session. Select a profile that corresponds to an Exchange mailbox.
The wizard now presents a list of folders with which to monitor for changes with ICS. Select all desired folders.
The wizard now prompts you as to whether you would like to build a Dialog based MFC application, a SDI, or a MDI application. The next set of windows depend on this selection and are standard for MFC wizards.
Once completed, the wizard sets up the new project, and creates the MFC framework code and code that performs the ICS synchronization. The folder information is stored in a file called FOLDER_EIDS.sav. When the wizard prompts you whether you would like to use MFC as a shared DLL or as a statically linked library, you must select "As a shared DLL." Selecting the statically linked library option will cause link errors with other runtime libraries (This is a known issue with this sample).
Add your custom code to the appropriate files.
Build the new application in the standard way. After building the executable, copy the file FOLDER_EIDS.sav to the build directory, Debug or Release. This file contains the profile and folder information needed to start the application. This file must always be present in the same directory as the executable.
Start the executable in the usual way.
Additional Notes
The file FOLDER_EIDS.sav contains information about selected folders for the application. This file must always be present in the same directory as the executable or the ICS synchronization will fail.
The NT Service saves the synchronization state in a file called synch.sav. Only one instance of the same service should be run at the same time. If more than one is run, information needed in this file may be destroyed by another service instance.
Make sure you modify the "Log On As" username and password for the service to be an account that has access to the folders specified when the project was built. If these values are incorrect, an error will be logged to the event service, and the service will fail to start properly.
Make sure to install the service before running it using the -install option for the executable.