home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 May / CHIPCD200305.iso / super / altn / md_en.exe / ITERATEUSERS.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  2002-04-26  |  1.0 KB  |  45 lines

  1. #include "IterateUsers.h"
  2. #include "MDUserImports.h"
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main(int argc, char** argv)
  7. {
  8.     
  9.     // Before calling any of the MDaemon functions you must first load the DLL
  10.  
  11.     int iLoadResult = 0;
  12.     if (!LoadMDUserDll(iLoadResult, // buffer to store error result code
  13.                       NULL,        // Optional path to the dll
  14.                       false))      // TRUE if you want the accounts loaded into memory after the dll has been initialized
  15.     {
  16.         cout << "Could not load the MDUserDll, error:" << iLoadResult << "\n";
  17.         return -1;
  18.     }
  19.  
  20.     
  21.     
  22.     MD_HANDLE hUser;
  23.     MD_FINDHANDLE hFind = MD_FindFirst(&hUser);
  24.     if (hFind != MD_BADFINDHANDLE)
  25.     {
  26.         do {
  27.             MD_UserInfo UserInfo;
  28.             MD_GetUserInfo(hUser, &UserInfo);
  29.             cout << "Found user: " << UserInfo.Email << "\n";
  30.         } while (MD_FindNext(hFind, &hUser));
  31.         
  32.         MD_FindClose(hFind);
  33.     }
  34.     else
  35.     {
  36.         // There was an error finding the first user
  37.         cout << "Error finding the first MDaemon user\n";
  38.     }
  39.  
  40.  
  41.     // Release the MDUserDLL
  42.     FreeMDUserDll();
  43.  
  44.     return 0;
  45. }