Examples of CEUTIL Functions

The following code example shows how to enumerate device partnerships and get the path for the file synchronization folder.

#include "ceutil.h"

void Example1 (void)
{
  // Note that this code runs on the desktop (or host) computer, 
  // and not on the Windows CEbased device, so set 
  // your project settings accordingly.

  HCESVC   hsvc            = NULL;
  HCESVC   hsvcSync        = NULL;
  HCESVC   hsvcProfile     = NULL;
  DWORD    cProfilesEnum   = 0;
  DWORD    nProfileID      = 0;

  while (SUCCEEDED (CeSvcEnumProfiles (&hsvc,
                                       cProfilesEnum,
                                       &nProfileID)))
  {
    if (nProfileID != (DWORD)-1)
    {
      if (SUCCEEDED (CeSvcOpenEx (hsvcProfile,
                                  TEXT("Services\\Synchronization"),
                                  FALSE, &hsvcSync)))
      {
        TCHAR szPath[MAX_PATH];

        if (SUCCEEDED (CeSvcGetString (hsvcSync,
                                       TEXT("Briefcase Path"),
                                       szPath,
                                       sizeof(szPath)/sizeof(TCHAR))))
        {
          // Found a path to use.

          // Your code to complete tasks goes here.
        }

        CeSvcClose (hsvcSync);
      }

      CeSvcClose (hsvcProfile);
    }
  }

  cProfilesEnum++;
}

The following code example shows how to add a custom menu.

{
  HCESVC hsvcMyMenu = NULL;

  if (SUCCEEDED (CeSvcOpen (CESVC_CUSTOM_MENUS,
                            TEXT("MyApp"), TRUE, &hsvcMyMenu)))
  {
    CeSvcSetString (hsvcMyMenu, TEXT("DisplayName"),
                    TEXT("&My Calculator"));

    CeSvcSetString (hsvcMyMenu, TEXT("Command"), TEXT("calc.exe"));

    CeSvcSetString (hsvcMyMenu, TEXT("StatusHelp"),
                    TEXT("Displays calculator"));

    CeSvcSetDword (hsvcMyMenu, TEXT("Version"), 0x00020000);

    CeSvcClose (hsvcMyMenu);
  }
}