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.

135 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. registry.c
  5. Abstract:
  6. Functions for accessing registry information under:
  7. HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE
  8. Environment:
  9. Windows XP fax driver user interface
  10. Revision History:
  11. 01/29/96 -davidx-
  12. Created it.
  13. mm/dd/yy -author-
  14. description
  15. --*/
  16. #include "faxlib.h"
  17. #include "registry.h"
  18. typedef BOOL (FAR WINAPI SHGETSPECIALFOLDERPATH)(
  19. HWND hwndOwner,
  20. LPTSTR lpszPath,
  21. int nFolder,
  22. BOOL fCreate
  23. );
  24. typedef SHGETSPECIALFOLDERPATH FAR *PSHGETSPECIALFOLDERPATH;
  25. PDEVMODE
  26. GetPerUserDevmode(
  27. LPTSTR pPrinterName
  28. )
  29. /*++
  30. Routine Description:
  31. Get per-user devmode information for the specified printer
  32. Arguments:
  33. pPrinterName - Specifies the name of the printer we're interested in
  34. Return Value:
  35. Pointer to per-user devmode information read from the registry
  36. --*/
  37. {
  38. PVOID pDevmode = NULL;
  39. HANDLE hPrinter;
  40. PPRINTER_INFO_2 pPrinterInfo=NULL;
  41. //
  42. // Make sure the printer name is valid
  43. //
  44. Assert (pPrinterName);
  45. //
  46. // Open the printer
  47. //
  48. if (!OpenPrinter(pPrinterName,&hPrinter,NULL) )
  49. {
  50. return NULL;
  51. }
  52. pPrinterInfo = MyGetPrinter(hPrinter,2);
  53. if (!pPrinterInfo || !pPrinterInfo->pDevMode)
  54. {
  55. MemFree(pPrinterInfo);
  56. ClosePrinter(hPrinter);
  57. return NULL;
  58. }
  59. pDevmode = MemAlloc(sizeof(DRVDEVMODE) );
  60. if (!pDevmode)
  61. {
  62. MemFree(pPrinterInfo);
  63. ClosePrinter(hPrinter);
  64. return NULL;
  65. }
  66. CopyMemory((PVOID) pDevmode,
  67. (PVOID) pPrinterInfo->pDevMode,
  68. sizeof(DRVDEVMODE) );
  69. MemFree( pPrinterInfo );
  70. ClosePrinter( hPrinter );
  71. return pDevmode;
  72. }
  73. LPTSTR
  74. GetUserCoverPageDir(
  75. VOID
  76. )
  77. {
  78. LPTSTR CpDir = NULL;
  79. DWORD dwBufferSize = MAX_PATH * sizeof(TCHAR);
  80. if (!(CpDir = MemAlloc(dwBufferSize)))
  81. {
  82. Error(("MemAlloc failed\n"));
  83. CpDir = NULL;
  84. return CpDir;
  85. }
  86. if(!GetClientCpDir(CpDir, dwBufferSize / sizeof (TCHAR)))
  87. {
  88. Error(("GetClientCpDir failed\n"));
  89. MemFree(CpDir);
  90. CpDir = NULL;
  91. return CpDir;
  92. }
  93. return CpDir;
  94. }