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.

86 lines
1.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: layapi.cxx
  7. //
  8. // Contents: API for layout tool
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 12-Feb-96 PhilipLa Created
  15. // 21-Feb-96 SusiA New API, moved ReLayoutDocfile to method
  16. //
  17. //----------------------------------------------------------------------------
  18. #include "layouthd.cxx"
  19. #pragma hdrstop
  20. #include <header.hxx>
  21. #include "laylkb.hxx"
  22. #include "laywrap.hxx"
  23. #if DBG == 1
  24. DECLARE_INFOLEVEL(lay);
  25. #endif
  26. STDAPI StgOpenLayoutDocfile(OLECHAR const *pwcsDfName,
  27. DWORD grfMode,
  28. DWORD reserved,
  29. IStorage **ppstgOpen)
  30. {
  31. SCODE sc;
  32. CLayoutLockBytes *pllkb;
  33. IStorage *pstg;
  34. if ((reserved != 0) || (!ppstgOpen))
  35. {
  36. return STG_E_INVALIDPARAMETER;
  37. }
  38. if (!(pwcsDfName))
  39. {
  40. return STG_E_INVALIDNAME;
  41. }
  42. pllkb = new CLayoutLockBytes();
  43. if (pllkb == NULL)
  44. {
  45. return STG_E_INSUFFICIENTMEMORY;
  46. }
  47. if (FAILED(sc = pllkb->Init(pwcsDfName, grfMode)))
  48. {
  49. pllkb->Release();
  50. return sc;
  51. }
  52. sc = StgOpenStorageOnILockBytes(pllkb,
  53. NULL,
  54. grfMode,
  55. NULL,
  56. 0,
  57. &pstg);
  58. if (FAILED(sc))
  59. {
  60. pllkb->Release();
  61. return sc;
  62. }
  63. *ppstgOpen = new CLayoutRootStorage(pstg, pllkb);
  64. if (*ppstgOpen == NULL)
  65. {
  66. pstg->Release();
  67. pllkb->Release();
  68. return STG_E_INSUFFICIENTMEMORY;
  69. }
  70. pstg->Release();
  71. pllkb->Release();
  72. return sc;
  73. }