| 2842 | } |
| 2843 | |
| 2844 | BOOL |
| 2845 | Ext2SetService(PCHAR Target, PCHAR Name, PCHAR Desc, BOOL bInstall) |
| 2846 | { |
| 2847 | SC_HANDLE hService; |
| 2848 | SC_HANDLE hManager; |
| 2849 | |
| 2850 | // open Service Control Manager |
| 2851 | hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); |
| 2852 | if (hManager == NULL) { |
| 2853 | // AfxMessageBox("Ext2Mgr: cannot open Service Control Manager", |
| 2854 | // MB_ICONEXCLAMATION | MB_OK); |
| 2855 | return FALSE; |
| 2856 | } |
| 2857 | |
| 2858 | if (bInstall) { |
| 2859 | |
| 2860 | // now create service entry |
| 2861 | hService = CreateService( |
| 2862 | hManager, // SCManager database |
| 2863 | Name, // name of service |
| 2864 | Desc, // name to display |
| 2865 | SERVICE_ALL_ACCESS, // desired access |
| 2866 | SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, |
| 2867 | // service type |
| 2868 | SERVICE_AUTO_START, // start type |
| 2869 | SERVICE_ERROR_NORMAL, // error control type |
| 2870 | Target, // service's binary |
| 2871 | NULL, // no load ordering group |
| 2872 | NULL, // no tag identifier |
| 2873 | NULL, // dependencies |
| 2874 | NULL, // LocalSystem account |
| 2875 | NULL); // no password |
| 2876 | |
| 2877 | if (hService == NULL) { |
| 2878 | DWORD error = GetLastError(); |
| 2879 | if (error == ERROR_SERVICE_EXISTS) { |
| 2880 | // AfxMessageBox("Service is already registered.", |
| 2881 | // MB_ICONEXCLAMATION | MB_OK); |
| 2882 | } else { |
| 2883 | // AfxMessageBox("Service couldn't be registered.", |
| 2884 | // MB_ICONEXCLAMATION | MB_OK); |
| 2885 | } |
| 2886 | } else { |
| 2887 | |
| 2888 | CloseServiceHandle(hService); |
| 2889 | } |
| 2890 | |
| 2891 | } else { |
| 2892 | |
| 2893 | /* open the service */ |
| 2894 | hService = OpenService( |
| 2895 | hManager, |
| 2896 | Name, |
| 2897 | SERVICE_ALL_ACCESS |
| 2898 | ); |
| 2899 | |
| 2900 | if (hService != NULL) { |
| 2901 |
no outgoing calls
no test coverage detected