Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.6 KiB

  1. #define INITGUID
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <ole2.h>
  5. #include "sync.h"
  6. BOOL g_fDone = FALSE;
  7. DWORD g_dwTarget = 0;
  8. SYNC_STAT* g_pStat = NULL;
  9. DWORD
  10. WINAPI
  11. Monitor(
  12. LPVOID pV
  13. )
  14. {
  15. for ( ;; )
  16. {
  17. printf( "Source : %d, %s, Targets : ",
  18. g_pStat->m_dwSourceScan,
  19. g_pStat->m_fSourceComplete ? "scanned" : "scanning" );
  20. for ( int i = 0 ; i < g_dwTarget ; ++i )
  21. {
  22. printf( "(%d,%d), ", g_pStat->m_adwTargets[i*2], g_pStat->m_adwTargets[i*2+1] );
  23. }
  24. printf( "\r" );
  25. if ( g_fDone )
  26. {
  27. break;
  28. }
  29. Sleep( 1000 );
  30. }
  31. return 0;
  32. }
  33. int __cdecl main( int argc, char*argv[] )
  34. {
  35. IMdSync* pIf;
  36. DWORD adwErr[16];
  37. HANDLE hThread;
  38. DWORD dwThreadId;
  39. g_pStat = (SYNC_STAT*)LocalAlloc( LMEM_FIXED, sizeof(SYNC_STAT)+sizeof(DWORD)*2*16 );
  40. memset ( g_pStat, '\0', sizeof(SYNC_STAT)+sizeof(DWORD)*2*16 );
  41. CoInitializeEx( NULL, COINIT_MULTITHREADED );
  42. if ( SUCCEEDED( CoCreateInstance( CLSID_MDSync, NULL, CLSCTX_INPROC_SERVER, IID_IMDSync, (LPVOID*)&pIf ) ) )
  43. {
  44. g_dwTarget = 1;
  45. hThread = CreateThread( NULL, 0, ::Monitor, NULL, 0, &dwThreadId );
  46. pIf->Synchronize( "phillich01\x0", adwErr, 0, (LPDWORD)g_pStat );
  47. g_fDone = TRUE;
  48. WaitForSingleObject( hThread, INFINITE );
  49. pIf->Release();
  50. }
  51. CoUninitialize();
  52. return 0;
  53. }