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.

212 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1994 - 1995 Microsoft Corporation
  3. Module Name:
  4. Drv.c
  5. Abstract:
  6. Test driver installation
  7. Author:
  8. Revision History:
  9. --*/
  10. #define NOMINMAX
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. #include <windows.h>
  15. #include <setupapi.h>
  16. #include <winspool.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include "..\splsetup.h"
  20. BOOL Dbg1 = TRUE;
  21. void
  22. DumpSelectedDriver(
  23. HDEVINFO hDevInfo
  24. );
  25. BOOL Dbg2 = TRUE;
  26. void
  27. DumpDriverInfo3(
  28. LPDRIVER_INFO_3 p3
  29. );
  30. BOOL Dbg3 = TRUE;
  31. void
  32. InstallDriver(
  33. HDEVINFO hDevInfo,
  34. HANDLE h
  35. );
  36. HDEVINFO hDevInfo;
  37. int
  38. #if !defined(_MIPS_) && !defined(_ALPHA_) && !defined(_PPC_)
  39. _cdecl
  40. #endif
  41. main (argc, argv)
  42. int argc;
  43. char *argv[];
  44. {
  45. DWORD dwLastError;
  46. hDevInfo = PSetupCreatePrinterDeviceInfoList(0);
  47. if ( hDevInfo == INVALID_HANDLE_VALUE ) {
  48. printf("%s: PSetupCreatePrinterDeviceInfoList fails with %d\n",
  49. argv[0], GetLastError());
  50. return 0;
  51. }
  52. do {
  53. PSetupSelectDriver(hDevInfo);
  54. dwLastError = GetLastError();
  55. if ( !dwLastError )
  56. DumpSelectedDriver(hDevInfo);
  57. if ( !PSetupRefreshDriverList(hDevInfo) ) {
  58. printf("%s: PSetupRefreshDriverList fails with %d\n",
  59. argv[0], GetLastError());
  60. }
  61. } while ( dwLastError == ERROR_SUCCESS);
  62. printf("%s: Exiting because of last error %d\n", argv[0], GetLastError());
  63. PSetupDestroyPrinterDeviceInfoList(hDevInfo);
  64. }
  65. void
  66. DumpSelectedDriver(
  67. HDEVINFO hDevInfo
  68. )
  69. {
  70. HANDLE h;
  71. DRIVER_FIELD DrvField;
  72. if ( !Dbg1 )
  73. return;
  74. h = PSetupGetSelectedDriverInfo(hDevInfo);
  75. if ( !h ) {
  76. printf("PSetupBuildDriverInfo fails with %d\n", GetLastError());
  77. return;
  78. }
  79. DrvField.Index = DRV_INFO_3;
  80. if ( !PSetupGetLocalDataField(h, PSetupThisPlatform(), &DrvField) ) {
  81. printf("PSetupGetLocalDataField fails with %d\n", GetLastError());
  82. return;
  83. }
  84. DumpDriverInfo3(DrvField.pDriverInfo3);
  85. InstallDriver(hDevInfo,
  86. h);
  87. Cleanup:
  88. PSetupFreeDrvField(&DrvField);
  89. PSetupDestroySelectedDriverInfo(h);
  90. }
  91. void
  92. DumpDriverInfo3(
  93. LPDRIVER_INFO_3 p3
  94. )
  95. {
  96. LPTSTR pp;
  97. printf("\tDriverInfo3:\n");
  98. printf("\t----------------------------------------------------------\n");
  99. printf("Driver Name : %ws\n", p3->pName);
  100. printf("Driver File : %ws\n", p3->pDriverPath);
  101. printf("Config File : %ws\n", p3->pConfigFile);
  102. printf("Data File : %ws\n", p3->pDataFile);
  103. printf("Help File : %ws\n", p3->pHelpFile);
  104. if ( p3->pDependentFiles && *p3->pDependentFiles ) {
  105. printf("Dependent File : ");
  106. for ( pp = p3->pDependentFiles; pp && *pp ; pp += wcslen(pp) + 1 )
  107. printf("%ws ", pp);
  108. printf("\n");
  109. } else
  110. printf("Dependent File : %ws\n", p3->pDependentFiles);
  111. printf("Monitor Name : %ws\n", p3->pMonitorName);
  112. printf("DefaultData : %ws\n", p3->pDefaultDataType);
  113. }
  114. void
  115. InstallDriver(
  116. HDEVINFO hDevInfo,
  117. HANDLE h
  118. )
  119. {
  120. DWORD dwLastError;
  121. if ( !Dbg3 )
  122. return;
  123. dwLastError = PSetupInstallPrinterDriver(hDevInfo,
  124. h,
  125. PlatformX86,
  126. 3,
  127. NULL,
  128. 0,
  129. L"X86",
  130. NULL);
  131. if ( dwLastError ) {
  132. printf(":PSetupeInstallPrinterDriver fails with %d\n", GetLastError());
  133. }
  134. dwLastError = PSetupInstallPrinterDriver(hDevInfo,
  135. h,
  136. PlatformMIPS,
  137. 3,
  138. NULL,
  139. 0,
  140. L"MIPS",
  141. NULL);
  142. if ( dwLastError ) {
  143. printf(":PSetupeInstallPrinterDriver fails with %d\n", GetLastError());
  144. }
  145. dwLastError = PSetupInstallPrinterDriver(hDevInfo,
  146. h,
  147. PlatformAlpha,
  148. 3,
  149. NULL,
  150. 0,
  151. L"Alpha",
  152. NULL);
  153. if ( dwLastError ) {
  154. printf(":PSetupeInstallPrinterDriver fails with %d\n", GetLastError());
  155. }
  156. }