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.

94 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name :
  4. guid.cpp
  5. Abstract:
  6. Initialization as required by initguid
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include <objbase.h>
  18. #include <initguid.h>
  19. #define INITGUID
  20. #include "iwamreg.h"
  21. #include "guid.h"
  22. int AppDeleteRecoverable_Wrap(LPCTSTR lpszPath)
  23. {
  24. int iReturn = FALSE;
  25. int iCoInitCalled = FALSE;
  26. TCHAR lpszKeyPath[_MAX_PATH];
  27. WCHAR wchKeyPath[_MAX_PATH];
  28. HRESULT hr = NOERROR;
  29. IWamAdmin* pIWamAdmin = NULL;
  30. if (lpszPath[0] == _T('/'))
  31. {
  32. _tcscpy(lpszKeyPath, lpszPath);
  33. }
  34. else
  35. {
  36. lpszKeyPath[0] = _T('/');
  37. _tcscpy(_tcsinc(lpszKeyPath), lpszPath);
  38. }
  39. #if defined(UNICODE) || defined(_UNICODE)
  40. _tcscpy(wchKeyPath, lpszKeyPath);
  41. #else
  42. MultiByteToWideChar(CP_ACP, 0, (LPCSTR)lpszKeyPath, -1, (LPWSTR)wchKeyPath, _MAX_PATH);
  43. #endif
  44. hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
  45. if (FAILED(hr))
  46. {
  47. iisDebugOut((_T("AppDeleteRecoverable_Wrap: CoInitializeEx() failed, hr=%x\n"), hr));
  48. goto AppDeleteRecoverable_Wrap_Exit;
  49. }
  50. // Set the flag to say that we need to call co-uninit
  51. iCoInitCalled = TRUE;
  52. hr = CoCreateInstance(CLSID_WamAdmin,NULL,CLSCTX_SERVER,IID_IWamAdmin,(void **)&pIWamAdmin);
  53. if (FAILED(hr))
  54. {
  55. iisDebugOut((_T("AppDeleteRecoverable_Wrap:CoCreateInstance() failed. err=%x.\n"), hr));
  56. goto AppDeleteRecoverable_Wrap_Exit;
  57. }
  58. hr = pIWamAdmin->AppDeleteRecoverable(wchKeyPath, TRUE);
  59. pIWamAdmin->Release();
  60. if (FAILED(hr))
  61. {
  62. iisDebugOut((_T("AppDeleteRecoverable_Wrap() on path %s failed, err=%x.\n"), lpszKeyPath, hr));
  63. goto AppDeleteRecoverable_Wrap_Exit;
  64. }
  65. // We got this far, everything must be okay.
  66. iReturn = TRUE;
  67. AppDeleteRecoverable_Wrap_Exit:
  68. if (iCoInitCalled == TRUE) {CoUninitialize();}
  69. return iReturn;
  70. }