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.

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