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.

201 lines
6.7 KiB

  1. // oleInst.h : Declaration of the COleInstall
  2. #ifndef __OLEINSTALL_H_
  3. #define __OLEINSTALL_H_
  4. #include "CPinst.h" // Template for connection point
  5. #define WM_ON_PROGRESS (WM_USER+100)
  6. #define WM_INSTALL_ERROR (WM_USER+101)
  7. #define FILEBUFSIZE 1024
  8. #define MAX_INET_RETRY 3
  9. #define RET_SUCCESS 1
  10. #define RET_SERVER_ERROR 2
  11. #define RET_OTHER_ERROR 3
  12. typedef class OleInstallData {
  13. public:
  14. LONG m_lCount;
  15. LPTSTR m_pszTempWebpnpFile;
  16. LPTSTR m_pPrinterUncName;
  17. LPTSTR m_pPrinterUrl;
  18. HWND m_hwnd;
  19. BOOL m_bValid;
  20. BOOL m_bRPC; // Should we do an RPC install?
  21. OleInstallData (LPTSTR pPrinterUncName,
  22. LPTSTR pPrinterUrl,
  23. HWND hwnd,
  24. BOOL m_bRPC);
  25. ~OleInstallData ();
  26. } OleInstallData;
  27. /////////////////////////////////////////////////////////////////////////////
  28. // COleInstall
  29. class ATL_NO_VTABLE COleInstall :
  30. public CComObjectRootEx<CComMultiThreadModel>,
  31. public CComCoClass<COleInstall, &CLSID_OleInstall>,
  32. public COlePrnSecComControl<COleInstall>,
  33. public IDispatchImpl<IOleInstall, &IID_IOleInstall, &LIBID_OLEPRNLib>,
  34. public IProvideClassInfo2Impl<&CLSID_OleInstall, &DIID__InstallEvent, &LIBID_OLEPRNLib>,
  35. public IPersistStreamInitImpl<COleInstall>,
  36. public IPersistStorageImpl<COleInstall>,
  37. public IQuickActivateImpl<COleInstall>,
  38. public IOleControlImpl<COleInstall>,
  39. public IOleObjectImpl<COleInstall>,
  40. public IOleInPlaceActiveObjectImpl<COleInstall>,
  41. public IViewObjectExImpl<COleInstall>,
  42. public IOleInPlaceObjectWindowlessImpl<COleInstall>,
  43. public IDataObjectImpl<COleInstall>,
  44. public ISpecifyPropertyPagesImpl<COleInstall>,
  45. public CProxy_InstallEvents<COleInstall>,
  46. public IConnectionPointContainerImpl<COleInstall>
  47. {
  48. public:
  49. DECLARE_REGISTRY_RESOURCEID(IDR_OLEINSTALL)
  50. BEGIN_COM_MAP(COleInstall)
  51. COM_INTERFACE_ENTRY(IOleInstall)
  52. COM_INTERFACE_ENTRY(IDispatch)
  53. COM_INTERFACE_ENTRY_IMPL(IViewObjectEx)
  54. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx)
  55. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx)
  56. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless)
  57. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
  58. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
  59. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject)
  60. COM_INTERFACE_ENTRY_IMPL(IOleControl)
  61. COM_INTERFACE_ENTRY_IMPL(IOleObject)
  62. COM_INTERFACE_ENTRY_IMPL(IQuickActivate)
  63. COM_INTERFACE_ENTRY_IMPL(IPersistStorage)
  64. COM_INTERFACE_ENTRY_IMPL(IPersistStreamInit)
  65. COM_INTERFACE_ENTRY_IMPL(ISpecifyPropertyPages)
  66. COM_INTERFACE_ENTRY_IMPL(IDataObject)
  67. COM_INTERFACE_ENTRY(IProvideClassInfo)
  68. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  69. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  70. COM_INTERFACE_ENTRY_IMPL(IObjectSafety)
  71. END_COM_MAP()
  72. BEGIN_PROPERTY_MAP(COleInstall)
  73. // Example entries
  74. // PROP_ENTRY("Property Description", dispid, clsid)
  75. PROP_PAGE(CLSID_StockColorPage)
  76. END_PROPERTY_MAP()
  77. BEGIN_CONNECTION_POINT_MAP(COleInstall)
  78. CONNECTION_POINT_ENTRY(DIID__InstallEvent)
  79. END_CONNECTION_POINT_MAP()
  80. BEGIN_MSG_MAP(COleInstall)
  81. MESSAGE_HANDLER(WM_PAINT, OnPaint)
  82. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  83. MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  84. END_MSG_MAP()
  85. // IViewObjectEx
  86. STDMETHOD(GetViewStatus)(DWORD* pdwStatus)
  87. {
  88. ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n"));
  89. *pdwStatus = VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE;
  90. return S_OK;
  91. }
  92. // IOleInstall
  93. public:
  94. STDMETHOD(OpenPrintersFolder)();
  95. STDMETHOD(InstallPrinter)(BSTR pbstrUncName, BSTR pbstrUrl);
  96. COleInstall();
  97. ~COleInstall();
  98. HRESULT OnDraw(ATL_DRAWINFO& di);
  99. private:
  100. HWND m_hwnd;
  101. LPTSTR m_pPrinterUncName; // holds the printers'UNC name
  102. LPTSTR m_pPrinterUrl; // holds the printer URL
  103. OleInstallData *m_pThreadData;
  104. HRESULT InitWin (BOOL bRPC);
  105. static LRESULT CALLBACK WndProc(
  106. HWND hWnd,
  107. UINT uMsg,
  108. WPARAM wParam,
  109. LPARAM lParam);
  110. static BOOL WorkingThread(
  111. void * pParam);
  112. static BOOL StartInstall(
  113. OleInstallData *pThreadData);
  114. static BOOL SyncExecute(
  115. LPTSTR pszFileName,
  116. int nShow);
  117. static DWORD GetWebpnpFile(
  118. OleInstallData *pData,
  119. LPTSTR pszURL,
  120. LPTSTR *ppErrMsg);
  121. static HANDLE GetTempFile(
  122. LPTSTR pExtension,
  123. LPTSTR * ppFileName);
  124. static BOOL IsHttpPreferred(void);
  125. static BOOL GetHttpPrinterFile(
  126. OleInstallData *pData,
  127. LPTSTR pbstrURL);
  128. static BOOL InstallHttpPrinter(
  129. OleInstallData *pData);
  130. static BOOL CheckAndSetDefaultPrinter(void);
  131. static BOOL UpdateUI (
  132. OleInstallData *pData,
  133. UINT message,
  134. WPARAM wParam);
  135. static BOOL UpdateProgress (
  136. OleInstallData *pData,
  137. DWORD dwProgress);
  138. static BOOL UpdateError (
  139. OleInstallData *pData);
  140. HRESULT CanIOpenPrintersFolder(void);
  141. HRESULT CanIInstallRPC(IN LPTSTR lpszPrinterUNC);
  142. HRESULT GetServerNameFromUNC(
  143. IN LPTSTR pszUNC,
  144. IN OUT LPTSTR *ppszServerName);
  145. HRESULT CheckServerForSpooler(
  146. IN LPTSTR pszServerName);
  147. static LPTSTR RemoveURLVars(LPTSTR); // Get rid of everything after ?
  148. static LPTSTR GetNTPrint(void);
  149. static LPTSTR CreatePrinterBaseName(
  150. LPCTSTR lpszPrinterURL,
  151. LPCTSTR lpszPrinterName);
  152. };
  153. #endif //__OLEINSTALL_H_
  154. /******************************************************************
  155. ** End of File (oleinst.h)
  156. ******************************************************************/