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.

187 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1994 - 1995 Microsoft Corporation
  3. Module Name:
  4. Ci.c
  5. Abstract:
  6. Class installer test program
  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 <cfgmgr32.h>
  16. #include <setupapi.h>
  17. #include <initguid.h>
  18. #include <devguid.h>
  19. #include <winspool.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include "..\splsetup.h"
  23. HDEVINFO hDevInfo;
  24. void
  25. DoInstallWizard(
  26. )
  27. {
  28. SP_INSTALLWIZARD_DATA InstWizData;
  29. ZeroMemory(&InstWizData, sizeof(SP_INSTALLWIZARD_DATA));
  30. InstWizData.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
  31. InstWizData.ClassInstallHeader.InstallFunction = DIF_INSTALLWIZARD;
  32. InstWizData.hwndWizardDlg = 0;
  33. if ( !SetupDiSetClassInstallParams(hDevInfo,
  34. NULL,
  35. &InstWizData.ClassInstallHeader,
  36. sizeof(InstWizData),
  37. NULL) ) {
  38. printf("SetupDiSetClassInstallParams fails with %d\n", GetLastError());
  39. return;
  40. }
  41. SetupDiCallClassInstaller(DIF_INSTALLWIZARD, hDevInfo, NULL);
  42. SetupDiCallClassInstaller(DIF_DESTROYWIZARDDATA, hDevInfo, NULL);
  43. }
  44. void
  45. InstallDevice(
  46. )
  47. {
  48. SP_DEVINFO_DATA DevInfoData;
  49. DWORD Error;
  50. HKEY hKey;
  51. do {
  52. PSetupSelectDriver(hDevInfo);
  53. if ( GetLastError() != ERROR_SUCCESS )
  54. break;
  55. DevInfoData.cbSize = sizeof(DevInfoData);
  56. if ( !SetupDiCreateDeviceInfo(hDevInfo,
  57. TEXT("Printer"),
  58. (LPGUID)&GUID_DEVCLASS_PRINTER,
  59. NULL,
  60. 0,
  61. DICD_GENERATE_ID | DICD_INHERIT_CLASSDRVS,
  62. &DevInfoData) ) {
  63. printf("SetupDiCreateDeviceInfo failed with %d\n", GetLastError());
  64. continue;
  65. }
  66. if ( Error = CM_Open_DevNode_Key(DevInfoData.DevInst,
  67. KEY_WRITE,
  68. 0,
  69. RegDisposition_OpenAlways,
  70. &hKey,
  71. CM_REGISTRY_HARDWARE) ) {
  72. printf("CM_Open_DevNode_Key failed with %d\n", Error);
  73. continue;
  74. }
  75. if ( Error = RegSetValueEx(hKey,
  76. TEXT("PortName"),
  77. NULL,
  78. REG_SZ,
  79. TEXT("LPT1:"),
  80. (lstrlen(TEXT("LPT1")) + 1 ) * sizeof(TCHAR)) ) {
  81. printf("RegSetValueEx failed with %d\n", Error);
  82. continue;
  83. }
  84. RegCloseKey(hKey);
  85. SetupDiCallClassInstaller(DIF_INSTALLDEVICE, hDevInfo, &DevInfoData);
  86. } while ( 1 );
  87. }
  88. void
  89. InstallDriver(
  90. )
  91. {
  92. }
  93. int
  94. #if !defined(_MIPS_) && !defined(_ALPHA_) && !defined(_PPC_)
  95. _cdecl
  96. #endif
  97. main (argc, argv)
  98. int argc;
  99. char *argv[];
  100. {
  101. DWORD dwLastError;
  102. hDevInfo = PSetupCreatePrinterDeviceInfoList(0);
  103. if ( hDevInfo == INVALID_HANDLE_VALUE ) {
  104. printf("%s: PSetupCreatePrinterDeviceInfoList fails with %d\n",
  105. argv[0], GetLastError());
  106. return 0;
  107. }
  108. DoInstallWizard();
  109. InstallDevice();
  110. PSetupDestroyPrinterDeviceInfoList(hDevInfo);
  111. }
  112. void
  113. DumpDriverInfo3(
  114. LPDRIVER_INFO_3 p3
  115. )
  116. {
  117. LPTSTR pp;
  118. printf("\tDriverInfo3:\n");
  119. printf("\t----------------------------------------------------------\n");
  120. printf("Driver Name : %ws\n", p3->pName);
  121. printf("Driver File : %ws\n", p3->pDriverPath);
  122. printf("Config File : %ws\n", p3->pConfigFile);
  123. printf("Data File : %ws\n", p3->pDataFile);
  124. printf("Help File : %ws\n", p3->pHelpFile);
  125. if ( p3->pDependentFiles && *p3->pDependentFiles ) {
  126. printf("Dependent File : ");
  127. for ( pp = p3->pDependentFiles; pp && *pp ; pp += wcslen(pp) + 1 )
  128. printf("%ws ", pp);
  129. printf("\n");
  130. } else
  131. printf("Dependent File : %ws\n", p3->pDependentFiles);
  132. printf("Monitor Name : %ws\n", p3->pMonitorName);
  133. printf("DefaultData : %ws\n", p3->pDefaultDataType);
  134. }
  135. void
  136. DumpSelectedDriver(
  137. HDEVINFO hDevInfo
  138. )
  139. {
  140. }