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.

69 lines
1.9 KiB

  1. #include "pch.cxx"
  2. #pragma hdrstop
  3. #include "teststub.cxx"
  4. #define TRKDATA_ALLOCATE
  5. #include "trksvr.hxx"
  6. #include "itrkadmn.h"
  7. DWORD g_Debug = 0xffffffff & ~TRKDBG_WORKMAN;
  8. const TCHAR tszKeyNameLinkTrack[] = TEXT("System\\CurrentControlSet\\Services\\TrkWks\\Parameters");
  9. EXTERN_C void __cdecl _tmain( ULONG cArgs, TCHAR *rgtszArgs[] )
  10. {
  11. TCHAR tsz[ MAX_PATH + 1 ];
  12. IBindCtx *pBC = NULL;
  13. IMoniker* pMnk = NULL;
  14. ITrkRestoreNotify *pTrkRestore = NULL;
  15. ULONG cchEaten = 0;
  16. HRESULT hr = E_FAIL;
  17. TrkDebugCreate( TRK_DBG_FLAGS_WRITE_TO_DBG | TRK_DBG_FLAGS_WRITE_TO_STDOUT, "TRestore" );
  18. CoInitialize(NULL);
  19. if( 1 >= cArgs )
  20. {
  21. printf( "\n"
  22. "This test takes a path and calls ITrkRestoreNotify on that machine\n" );
  23. printf( "Usage: TRestore <path>\n" );
  24. printf( "E.g.: TRestore \\\\machine\\share\\dir\\path.ext\n" );
  25. goto Exit;
  26. }
  27. __try
  28. {
  29. _tcscpy( tsz, TEXT("@LinkTrack@") );
  30. _tcscat( tsz, rgtszArgs[1] );
  31. // Get the moniker
  32. CreateBindCtx( 0, &pBC );
  33. hr = MkParseDisplayName( pBC, tsz, &cchEaten, &pMnk );
  34. if( FAILED(hr) ) TrkRaiseException( hr );
  35. // Get the ITrkRestoreNotify object
  36. hr = pMnk->BindToObject( pBC, NULL, IID_ITrkRestoreNotify, reinterpret_cast<void**>(&pTrkRestore) );
  37. if( FAILED(hr) ) TrkRaiseException( hr );
  38. // Do the notification
  39. hr = pTrkRestore->OnRestore();
  40. if( FAILED(hr) ) TrkRaiseException( hr );
  41. }
  42. __except( BreakOnDebuggableException() )
  43. {
  44. TrkAssert( STATUS_ACCESS_VIOLATION != GetExceptionCode() );
  45. TrkLog(( TRKDBG_ERROR, TEXT("Exception %d caught in TRestore\n"), GetExceptionCode() ));
  46. }
  47. Exit:
  48. if( SUCCEEDED(hr) ) printf("Passed\n");
  49. return;
  50. }