Windows NT 4.0 source code leak
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.

175 lines
3.6 KiB

4 years ago
  1. /****************************************************************************
  2. *
  3. * config.c
  4. *
  5. * Copyright (c) 1991 Microsoft Corporation. All Rights Reserved.
  6. *
  7. ***************************************************************************/
  8. #include <windows.h>
  9. #include <mmsystem.h>
  10. #include <soundcfg.h>
  11. #include "driver.h"
  12. #include "registry.h"
  13. #include <stdarg.h>
  14. #include "config.h"
  15. #define BUILD_NUMBER L"1.00"
  16. #if DBG
  17. WCHAR STR_CRLF[] = L"\r\n";
  18. WCHAR STR_SPACE[] = L" ";
  19. WORD wDebugLevel = 0;
  20. #endif
  21. /*
  22. * Globals
  23. */
  24. HMODULE ghModule;
  25. REG_ACCESS RegAccess;
  26. //
  27. // Configuration data
  28. //
  29. WCHAR gszHelpFile[] = STR_HELPFILE;
  30. /** void FAR cdecl AlertBox(HWND hwnd, UINT wStrId, ...)
  31. *
  32. * DESCRIPTION:
  33. *
  34. *
  35. * ARGUMENTS:
  36. * (HWND hwnd, UINT wStrId, ...)
  37. *
  38. * RETURN (void FAR cdecl):
  39. *
  40. *
  41. * NOTES:
  42. *
  43. ** cjp */
  44. void AlertBox(HWND hwnd, UINT wStrId, ...)
  45. {
  46. WCHAR szAlert[50];
  47. WCHAR szFormat[128];
  48. WCHAR ach[512];
  49. va_list va;
  50. LoadString(ghModule, SR_ALERT, szAlert, sizeof(szAlert));
  51. LoadString(ghModule, wStrId, szFormat, sizeof(szFormat));
  52. va_start(va, wStrId);
  53. wvsprintf(ach, szFormat, va);
  54. va_end(va);
  55. MessageBox(hwnd, ach, szAlert, MB_ICONINFORMATION | MB_OK);
  56. } /* AlertBox() */
  57. /*
  58. * load the kernel driver and tell the user we are loaded
  59. */
  60. int DrvInstall(void)
  61. {
  62. if (DrvCreateServicesNode(STR_DRIVERNAME, SoundDriverTypeSynth, &RegAccess,
  63. TRUE)) {
  64. if (DrvIsDriverLoaded(&RegAccess) ||
  65. DrvLoadKernelDriver(&RegAccess)) {
  66. DrvCreateParamsKey(&RegAccess);
  67. return(DRV_RESTART);
  68. } else {
  69. /*
  70. * If the kernel driver fails to load we don't want to
  71. * leave the services node entry lying around.
  72. */
  73. DrvDeleteServicesNode(&RegAccess);
  74. }
  75. }
  76. DrvCloseServiceManager(&RegAccess);
  77. return(DRV_CANCEL);
  78. }
  79. /*************************************************************************
  80. DlgAboutProc - dialog box for the "About" option.
  81. standard windows
  82. */
  83. int DlgAboutProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  84. {
  85. switch (message){
  86. case WM_INITDIALOG:
  87. SetDlgItemText(hDlg, IDD_TXT_VERSION, BUILD_NUMBER);
  88. return TRUE;
  89. case WM_COMMAND:
  90. switch (wParam){
  91. case IDOK:
  92. EndDialog(hDlg,0);
  93. return TRUE;
  94. }
  95. break;
  96. }
  97. return FALSE;
  98. }
  99. /***************************************************************************/
  100. LRESULT ConfigRemove(HWND hDlg)
  101. {
  102. BOOL Deleted;
  103. //
  104. // Access the services node
  105. //
  106. if (DrvCreateServicesNode(STR_DRIVERNAME, SoundDriverTypeSynth, &RegAccess,
  107. FALSE)) {
  108. //
  109. // Try to unload the driver
  110. //
  111. DrvUnloadKernelDriver(&RegAccess);
  112. //
  113. // Remove the driver entry from the registry
  114. //
  115. // Note - the user should normally restart because (for instance)
  116. // the dll will remain loaded on all processes linked to winmm until
  117. // restart so no new version will be installable.
  118. //
  119. Deleted = DrvDeleteServicesNode(&RegAccess);
  120. } else {
  121. Deleted = TRUE;
  122. }
  123. //
  124. // Make sure we've freed all our registry handles
  125. //
  126. DrvCloseServiceManager(&RegAccess);
  127. if (!Deleted) {
  128. //
  129. // Tell the user there's a problem
  130. //
  131. AlertBox(hDlg, SR_ALERT_FAILREMOVE);
  132. return DRVCNF_CANCEL;
  133. } else {
  134. return DRVCNF_RESTART;
  135. }
  136. }