Source code of Windows XP (NT5)
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.

171 lines
3.3 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. main.cpp
  5. Abstract:
  6. This file contains the unit test for the Security objects.
  7. Revision History:
  8. Davide Massarenti (Dmassare) 03/22/2000
  9. created
  10. ******************************************************************************/
  11. #include "StdAfx.h"
  12. #include <initguid.h>
  13. #include "HCApi_i.c"
  14. ////////////////////////////////////////////////////////////////////////////////
  15. static HRESULT Create( IPCHLaunch* *obj )
  16. {
  17. return ::CoCreateInstance( CLSID_PCHLaunch, NULL, CLSCTX_ALL, IID_IPCHLaunch, (void**)obj );
  18. }
  19. static HRESULT SimpleOpen()
  20. {
  21. __HCP_FUNC_ENTRY( "SimpleOpen" );
  22. HRESULT hr;
  23. CComPtr<IPCHLaunch> obj;
  24. __MPC_EXIT_IF_METHOD_FAILS(hr, Create( &obj ));
  25. __MPC_EXIT_IF_METHOD_FAILS(hr, obj->PopUp());
  26. hr = S_OK;
  27. __HCP_FUNC_CLEANUP;
  28. __HCP_FUNC_EXIT(hr);
  29. }
  30. static HRESULT OpenWithSizeAndContext( LPCWSTR ctx )
  31. {
  32. __HCP_FUNC_ENTRY( "OpenWithSizeAndContext" );
  33. HRESULT hr;
  34. CComPtr<IPCHLaunch> obj;
  35. __MPC_EXIT_IF_METHOD_FAILS(hr, Create( &obj ));
  36. __MPC_EXIT_IF_METHOD_FAILS(hr, obj->SetSizeInfo( 20, 20, 300, 300 ));
  37. __MPC_EXIT_IF_METHOD_FAILS(hr, obj->DisplayTopic( CComBSTR( ctx ) ));
  38. hr = S_OK;
  39. __HCP_FUNC_CLEANUP;
  40. __HCP_FUNC_EXIT(hr);
  41. }
  42. static HRESULT OpenOnTop( LPCWSTR ctx, LPCWSTR win )
  43. {
  44. __HCP_FUNC_ENTRY( "OpenOnTop" );
  45. HRESULT hr;
  46. CComPtr<IPCHLaunch> obj;
  47. HWND hwnd;
  48. __MPC_EXIT_IF_METHOD_FAILS(hr, Create( &obj ));
  49. hwnd = ::FindWindowW( win, NULL );
  50. __MPC_EXIT_IF_METHOD_FAILS(hr, obj->SetParentWindow( hwnd ));
  51. __MPC_EXIT_IF_METHOD_FAILS(hr, obj->DisplayTopic( CComBSTR( ctx ) ));
  52. hr = S_OK;
  53. __HCP_FUNC_CLEANUP;
  54. __HCP_FUNC_EXIT(hr);
  55. }
  56. static HRESULT WaitUntilExit()
  57. {
  58. __HCP_FUNC_ENTRY( "WaitUntilExit" );
  59. HRESULT hr;
  60. CComPtr<IPCHLaunch> obj;
  61. __MPC_EXIT_IF_METHOD_FAILS(hr, Create( &obj ));
  62. __MPC_EXIT_IF_METHOD_FAILS(hr, obj->WaitForTermination( INFINITE ));
  63. hr = S_OK;
  64. __HCP_FUNC_CLEANUP;
  65. __HCP_FUNC_EXIT(hr);
  66. }
  67. ////////////////////////////////////////////////////////////////////////////////
  68. static HRESULT RunTests( int argc, WCHAR **argv )
  69. {
  70. __HCP_FUNC_ENTRY( "RunTests" );
  71. HRESULT hr;
  72. int i;
  73. for(i=1; i<argc;)
  74. {
  75. LPCWSTR szArg = argv[i++];
  76. if(!_wcsicmp( szArg, L"SimpleOpen" ))
  77. {
  78. __MPC_EXIT_IF_METHOD_FAILS(hr, SimpleOpen());
  79. }
  80. else if(!_wcsicmp( szArg, L"OpenWithSizeAndContext" ))
  81. {
  82. LPCWSTR ctx = (i<argc) ? argv[i++] : L"hcp://system/index.htm";
  83. __MPC_EXIT_IF_METHOD_FAILS(hr, OpenWithSizeAndContext( ctx ));
  84. }
  85. else if(!_wcsicmp( szArg, L"OpenOnTop" ))
  86. {
  87. LPCWSTR win = (i<argc) ? argv[i++] : L"Notepad";
  88. LPCWSTR ctx = (i<argc) ? argv[i++] : L"hcp://system/homepage.htm";
  89. __MPC_EXIT_IF_METHOD_FAILS(hr, OpenOnTop( ctx, win ));
  90. }
  91. else if(!_wcsicmp( szArg, L"WaitUntilExit" ))
  92. {
  93. __MPC_EXIT_IF_METHOD_FAILS(hr, WaitUntilExit());
  94. }
  95. }
  96. hr = S_OK;
  97. __HCP_FUNC_CLEANUP;
  98. __HCP_FUNC_EXIT(hr);
  99. }
  100. int __cdecl wmain( int argc, WCHAR **argv, WCHAR **envp)
  101. {
  102. HRESULT hr;
  103. if(SUCCEEDED(hr = ::CoInitializeEx( NULL, COINIT_MULTITHREADED )))
  104. {
  105. hr = RunTests( argc, argv );
  106. ::CoUninitialize();
  107. }
  108. return FAILED(hr) ? 10 : 0;
  109. }