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.

119 lines
2.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: install.cxx
  7. //
  8. // Contents: Routines for queries/install of application state in the DS.
  9. //
  10. // Functions:
  11. //
  12. // History: Feb-97 DKays Created
  13. // Nov-97 DebiM Changed for Beta2
  14. //
  15. //--------------------------------------------------------------------------
  16. #include "act.hxx"
  17. #ifdef DIRECTORY_SERVICE
  18. HRESULT DarwinPackageAssign( LPCWSTR pwszScript, BOOL InstallNow );
  19. //+-------------------------------------------------------------------------
  20. //
  21. // CSGetClass
  22. //
  23. // Attempts to lookup and possibly install a class.
  24. //
  25. //--------------------------------------------------------------------------
  26. HRESULT CSGetClass(
  27. DWORD dwFlags,
  28. uCLSSPEC * pClassSpec,
  29. QUERYCONTEXT * pQueryContext,
  30. CLSID * pClsid,
  31. INSTALLINFO ** ppInstallInfo
  32. )
  33. {
  34. HRESULT hr;
  35. INSTALLINFO InstallInfo;
  36. *pClsid = CLSID_NULL;
  37. *ppInstallInfo = 0;
  38. /*
  39. if ( ! gpClassAccess )
  40. return CS_E_NO_CLASSSTORE;
  41. hr = gpClassAccess->GetAppInfo( pClassSpec, &QueryContext, &InstallInfo );
  42. */
  43. //
  44. // Impersonate as calling user
  45. // Do ClassStore Lookup
  46. //
  47. hr = RpcImpersonateClient( NULL );
  48. if (hr != RPC_S_OK)
  49. return hr;
  50. hr = CsGetAppInfo( pClassSpec, pQueryContext, &InstallInfo );
  51. RevertToSelf();
  52. if ( hr != S_OK )
  53. return hr;
  54. //
  55. // Only one package is returned.
  56. //
  57. if ( DrwFilePath == InstallInfo.PathType )
  58. {
  59. hr = DarwinPackageAssign( InstallInfo.pszScriptPath, FALSE );
  60. }
  61. else
  62. {
  63. //
  64. // Return one of the ClassIDs. This is for IE use only.
  65. //
  66. if ( pClassSpec->tyspec != TYSPEC_CLSID )
  67. {
  68. if ( InstallInfo.pClsid )
  69. *pClsid = *(InstallInfo.pClsid);
  70. }
  71. }
  72. *ppInstallInfo = (INSTALLINFO *) CoTaskMemAlloc (sizeof(INSTALLINFO));
  73. memcpy( *ppInstallInfo, &InstallInfo, sizeof(INSTALLINFO) );
  74. return hr;
  75. }
  76. HRESULT
  77. DarwinPackageAssign(
  78. IN LPCWSTR pwszScript,
  79. IN BOOL InstallNow )
  80. {
  81. BOOL bStatus;
  82. HRESULT hr;
  83. hr = RpcImpersonateClient( NULL );
  84. if (hr != RPC_S_OK) {
  85. return hr;
  86. }
  87. bStatus = AssignApplication( pwszScript, InstallNow );
  88. RevertToSelf();
  89. if ( ! bStatus )
  90. return HRESULT_FROM_WIN32( GetLastError() );
  91. return S_OK;
  92. }
  93. #endif // DIRECTORY_SERVICE