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.

404 lines
10 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. All rights reserved.
  4. Module Name:
  5. rundll.cxx
  6. Abstract:
  7. Run dll entry interface for lauching printer related
  8. UI from shell extenstion and other shell related components.
  9. Author:
  10. Steve Kiraly (SteveKi) 29-Sept-1996
  11. Revision History:
  12. --*/
  13. #ifndef _RUNDLL_HXX
  14. #define _RUNDLL_HXX
  15. /********************************************************************
  16. Printer commnad types.
  17. ********************************************************************/
  18. enum {
  19. kProperties, // Printer properties
  20. kWin32QueueView, // Printer queue view
  21. kInstallNetPrinter, // Install connection to network printer
  22. kDeleteNetPrinter, // Delete printer connection
  23. kInstallLocalPrinter, // Install printer wizard
  24. kInstallPrinterWithInf, // Install printer using an inf file
  25. kDeleteLocalPrinter, // Delete printer wizard
  26. kServerProperties, // Print server properties
  27. kDocumentDefaults, // Document defaults
  28. kInstallPrinterDriver, // Install printer driver
  29. kInstallLocalPrinterWithInf, // Install printer wizard
  30. kAddPerMachineConnection, // Add per machine printer connection
  31. kDeletePerMachineConnection, // Delete per machine printer connection
  32. kEnumPerMachineConnections, // Enumerate per machine printer connection
  33. kInstallDriverWithInf, // Instal printer driver with inf
  34. kDeletePrinterDriver, // Delete printer driver
  35. kSetAsDefault, // Set printer as the default printer
  36. kPrintTestPage, // Print the test page
  37. kPrinterGetSettings, // Get printer settings, comment, location, port etc.
  38. kPrinterSetSettings, // Set printer settings, comment, location, port etc.
  39. kCommandHelp, // Command specific help
  40. kPrinterPersist, // Persist printer settings into file
  41. kPrinterRestore, // Restore printer settings from file
  42. kUnknown // Unknown command type
  43. };
  44. enum {
  45. kMsgUnknownType, // The message type is unknown
  46. kMsgConfirmation, // The message type is question (MB_ICONQUESTION)
  47. kMsgWarning, // The message type is warning (MB_ICONEXCLAMATION)
  48. };
  49. struct AFlags {
  50. UINT IsQuiet:1; // Quiet flag
  51. UINT IsSupressSetupUI:1; // Super quiet flag (supress setup warnings UI)
  52. UINT IsWebPointAndPrint:1; // Used for web point and print
  53. UINT IsNoSharing:1; // Is not to be shared
  54. UINT IsUseExistingDriver:1; // Use exsiting driver if installed when adding a printer
  55. UINT IsUnknownDriverPrompt:1; // Prompt if driver is not known
  56. UINT IsPromptForNeededFiles:1; // Prompt if files are needed
  57. UINT IsHydraSpecific:1; // Hydra specific flag
  58. UINT IsShared:1; // Caller wants the printer shared
  59. UINT IsWindowsUpdate:1; // Windows Update case, we need to ignore ths INF file.
  60. UINT IsDontAutoGenerateName:1; // Don't auto generate a mangled printer name
  61. UINT IsUseNonLocalizedStrings:1; // Use non localized strings Environment and Version
  62. UINT IsWizardRestartable:1; // Is the wizard (APW & APDW) restartable from the last page
  63. };
  64. struct AParams {
  65. AFlags Flags; // Flags
  66. INT dwSheet; // Property sheet to start on
  67. LPTSTR pPrinterName; // Printer or server name
  68. LPTSTR pPortName; // Port name
  69. LPTSTR pModelName; // Printer model name
  70. LPTSTR pInfFileName; // INF path and file name
  71. LPTSTR pBasePrinterName; // INF install base printer name
  72. DWORD dwLastError; // Last error of command
  73. LPTSTR pMachineName; // Machine to act on
  74. LPTSTR pSourcePath; // Driver sources path inf installation
  75. LPCTSTR pszCmdLine; // Original command line passed to rundll32.exe
  76. LPTSTR pBinFileName; // Binary file holds devmode & printer data
  77. LPTSTR pProvider; // Name of the Print Provider
  78. LPTSTR pVersion; // Driver version
  79. LPTSTR pArchitecture; // Driver architecture
  80. LPTSTR pAttribute; // Print queue attribute name
  81. LPTSTR pMsgConfirm; // Message confirmation text
  82. UINT uMsgType; // Message type (can be question or warning)
  83. UINT ac; // Remaining argument count
  84. LPTSTR *av; // Remaining arguments
  85. };
  86. /********************************************************************
  87. Run DLL command interface. Note the W appended to this function
  88. is neccessary to indicate to rundll32.exe that this interface
  89. accepts unicode characters only.
  90. rundll32.exe commands are of the form.
  91. rundll32 DLL,FunctionName Args
  92. Args is text string just like any command line argument.
  93. Example:
  94. rundll32 printui.dll,PrintUIEntry /o /d \\steveki1\test_printer
  95. This command will load the printui.dll library and call the
  96. function PrintUIEntryW with the following command line arguments.
  97. "/o /d \\steveki1\test_printer"
  98. In this example a queue for \\steveki1\test_printer will be
  99. opened and displayed.
  100. Note: All arguments are case sensitive.
  101. See the function PrintUIEntryW for command specific information.
  102. ********************************************************************/
  103. DWORD
  104. PrintUIEntryW(
  105. IN HWND hwnd,
  106. IN HINSTANCE hInstance,
  107. IN LPCTSTR pszCmdLine,
  108. IN UINT nCmdShow
  109. );
  110. BOOL
  111. bValidateCommand(
  112. IN INT iFunction,
  113. IN AParams *pParams
  114. );
  115. BOOL
  116. bExecuteCommand(
  117. IN HWND hwnd,
  118. IN INT iFunction,
  119. IN AParams *Params
  120. );
  121. BOOL
  122. bDoCommand(
  123. IN HWND hwnd,
  124. IN INT ac,
  125. IN LPTSTR *av,
  126. IN AParams *pParams
  127. );
  128. BOOL
  129. bDoInfPrinterInstall(
  130. IN AParams *pParams
  131. );
  132. BOOL
  133. bDoInfDriverInstall(
  134. IN AParams *pParams
  135. );
  136. VOID
  137. vUsage(
  138. IN AParams *pParams
  139. );
  140. BOOL
  141. bDoPersistPrinterSettings(
  142. IN INT iFunction,
  143. IN AParams *pParams
  144. );
  145. BOOL
  146. bDoWebPnpPreInstall(
  147. IN AParams *pParams
  148. );
  149. BOOL
  150. bDoDriverRemoval(
  151. IN AParams *pParams
  152. );
  153. BOOL
  154. bDoGetPrintSettings(
  155. IN AParams *pParams
  156. );
  157. BOOL
  158. bDoSetPrintSettings(
  159. IN AParams *pParams
  160. );
  161. BOOL
  162. PrintSettings_ValidateArguments(
  163. IN AParams *pParams
  164. );
  165. BOOL
  166. PrintSettings_SetInfo(
  167. IN AParams *pParams,
  168. IN PRINTER_INFO_2 &Info
  169. );
  170. BOOL
  171. PrintSettings_DisplayHelp(
  172. IN AParams *pParams,
  173. IN TSelect::Selection *pSelection
  174. );
  175. BOOL
  176. PrintSettings_DisplayInformation(
  177. IN AParams *pParams,
  178. IN TSelect::Selection *pSelection
  179. );
  180. BOOL
  181. PrintSettings_DisplayAttributes(
  182. IN TString &strBit,
  183. IN TSelect::Selection *pSelection,
  184. IN UINT uAttributes
  185. );
  186. BOOL
  187. PrintSettings_DisplayStatus(
  188. IN TString &strVal,
  189. IN TSelect::Selection *pSelection,
  190. IN UINT uStatus
  191. );
  192. /********************************************************************
  193. Very simple file output class.
  194. ********************************************************************/
  195. class TFile {
  196. public:
  197. enum FilePrefix {
  198. kUnicodePrefix = 0xFEFF
  199. };
  200. TFile(
  201. IN LPCTSTR pszFileName,
  202. IN BOOL bNoUnicodeByteMark = FALSE
  203. );
  204. ~TFile(
  205. VOID
  206. );
  207. BOOL
  208. bValid(
  209. VOID
  210. );
  211. BOOL
  212. bWrite(
  213. IN TString &strString,
  214. OUT UINT *pBytesWritten = NULL
  215. );
  216. BOOL
  217. bWrite(
  218. IN UINT uSize,
  219. IN LPBYTE pData,
  220. OUT UINT *pBytesWritten = NULL
  221. );
  222. private:
  223. //
  224. // Assignment and copying are not defined
  225. //
  226. TFile &
  227. operator =(
  228. const TFile &
  229. );
  230. TFile(
  231. const TFile &
  232. );
  233. HANDLE _hFile;
  234. TString _strFileName;
  235. BOOL _bValid;
  236. };
  237. /********************************************************************
  238. RunDllDisplay
  239. ********************************************************************/
  240. class TRunDllDisplay : public MGenericDialog {
  241. public:
  242. enum DisplayType {
  243. kEditBox,
  244. kFile,
  245. };
  246. TRunDllDisplay(
  247. IN HWND hWnd,
  248. IN LPCTSTR pszFileName = NULL,
  249. IN DisplayType Display = kEditBox
  250. );
  251. ~TRunDllDisplay(
  252. VOID
  253. );
  254. BOOL
  255. bValid(
  256. VOID
  257. );
  258. BOOL
  259. bDoModal(
  260. VOID
  261. );
  262. BOOL
  263. WriteOut(
  264. LPCTSTR pszData
  265. );
  266. BOOL
  267. SetTitle(
  268. LPCTSTR pszData
  269. );
  270. VOID
  271. vSetTabStops(
  272. IN UINT uTabStop
  273. );
  274. private:
  275. //
  276. // Assignment and copying are not defined
  277. //
  278. TRunDllDisplay &
  279. operator =(
  280. const TRunDllDisplay &
  281. );
  282. TRunDllDisplay(
  283. const TRunDllDisplay &
  284. );
  285. BOOL
  286. bSetUI(
  287. VOID
  288. );
  289. BOOL
  290. bHandle_WM_SIZE(
  291. IN WPARAM wParam,
  292. IN LPARAM lParam
  293. );
  294. BOOL
  295. bHandle_WM_GETMINMAXINFO(
  296. IN WPARAM wParam,
  297. IN LPARAM lParam
  298. );
  299. BOOL
  300. bHandleMessage(
  301. IN UINT uMsg,
  302. IN WPARAM wParam,
  303. IN LPARAM lParam
  304. );
  305. HWND _hWnd;
  306. BOOL _bValid;
  307. DisplayType _Display;
  308. TString _StringOutput;
  309. TString _StringTitle;
  310. TFile *_pFile;
  311. POINT _ptLastSize;
  312. POINT _ptMinTrack;
  313. INT _cxGrip;
  314. INT _cyGrip;
  315. HWND _hwndGrip;
  316. UINT _cTabStop;
  317. DWORD _dwTabStop;
  318. };
  319. #endif