May 21, 2019
Hot Topics:

Understanding Mobile Data Synchronization: Creating Custom File Filters

  • September 1, 2005
  • By Alex Gusev
  • Send Email »
  • More Articles »

Registering the File Filter

Well, you have successfully developed your great file filter and you can be proud of it. The only thing left is to kindly inform MS ActiveSync that the new filter exists and how to use it. You have several options about to do it:

  • Create a separate Install/Uninstall application.
  • Implement and export DllRegisterServer/DllUnregisterServer functions inside your file filter.
  • Create a REG file with all required information.

The first two options give you more power because you will be able to enumerate all existing device profiles and set up your filter there as well as for future connections. The REG file will do only for future connections. Let me place it here in case you're interested:

; Register COM Object itself
@="Developer.com Sample Filter"
"Description"="Copy DAT file with A2W conversion"
; DAT file stuff
@="PC DAT File"
; LOG file stuff
@="PDA LOG File"
; Register Our Filter under WinCE Services root
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows CE ServicesFilters.dat]
"DefaultExport"="Binary Copy"
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows CE ServicesFilters

As you see, this is just regular registration stuff. Thus, you may see the results of your effort in the following figure:

Now, if you try to copy a DAT file from the desktop to the PDA, it will be converted to the selected code page.

Using the File Filter Manually

To use any file filter from your application directly, you have to recreate ActiveSync flow; for example:

  1. Implement an ICeFileFilterSite interface.
  2. Create an instance of the file filter.
  3. Fill in all structs for the source and destination files.
  4. Call ICeFileFilter::NextConvertFile.
  5. Release all stuff.

You do not need to bother implementing a full COM object for ICeFileFilterSite. Simply inherit a class from this interface and use it later on. You will find such a sample object in the accompanying zip. As a final comment, I'll give you this tiny code snippet that performs manual file conversion:

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
   int nRetCode = 0;
   // initialize MFC and print and error on failure
   if (!AfxWinInit(::GetModuleHandle(NULL), NULL,
       ::GetCommandLine(), 0))
      // TODO: change error code to suit your needs
      cerr << _T("Fatal Error: MFC initialization failed") << endl;
      nRetCode = 1;
      return nRetCode;
   ICeFileFilter *pFilter = NULL;
   HRESULT hr = 0;
   hr = ::CoCreateInstance(CLSID_Dat2LogFileFilter,0,CLSCTX_SERVER,
   CCeFilterSite site;
   site.m_sSrcFile = "d:\Sample.dat";
   CFF_CONVERTINFO convertInfo;
   convertInfo.bImport = TRUE;
   convertInfo.hwndParent = NULL;
   convertInfo.bYesToAll = FALSE;
   convertInfo.pffs = &site;
   CFF_SOURCEFILE sourceFile;
   _tcscpy(sourceFile.szFullpath, _T(""));
   _tcscpy(destFile.szFullpath, _T("d:\Sample.log"));
   CF_ERROR error;
   BOOL bCancel = FALSE;
   hr = pFilter->NextConvertFile(0, &convertInfo, &sourceFile,
                                 &destFile, &bCancel, &error);
   return nRetCode;


In this article, you have played around with one more MS ActiveSync supported feature. Along with the connection notifications discussed previously, it already gives you a wide elbowroom for powerful implementations. If all goes smoothly, the next articles will show you how to develop more complicated stuff, ActiveSync Service Provider components.


Download the accompanying code's zip file here

About the Author

Alex Gusev started to play with mainframes at the end of the 1980s, using Pascal and REXX, but soon switched to C/C++ and Java on different platforms. When mobile PDAs seriously rose their heads in the IT market, Alex did it too. Now, he works at an international retail software company as a team leader of the Mobile R department, making programmers' lives in the mobile jungles a little bit simpler.

Page 3 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date