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