Leaked source code of windows server 2003
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.

111 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. credavsrv.c
  5. Abstract:
  6. This is the module that helps install the DAV service in a SCM database.
  7. Author:
  8. Rohan Kumar [RohanK] 08-Feb-2000
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. --*/
  13. #include <stdio.h>
  14. #include <windows.h>
  15. #include <winsvc.h>
  16. #include <string.h>
  17. #define UNICODE
  18. #define _UNICODE
  19. VOID
  20. _cdecl
  21. main(
  22. IN INT ArgC,
  23. IN PCHAR ArgV[]
  24. )
  25. /*++
  26. Routine Description:
  27. Main function that installs the service.
  28. Arguments:
  29. ArgC - Number of arguments.
  30. ArgV - Array of arguments.
  31. Return Value:
  32. None.
  33. --*/
  34. {
  35. ULONG WStatus = ERROR_SUCCESS;
  36. SC_HANDLE SCMHandle = NULL;
  37. SC_HANDLE DavServiceHandle = NULL;
  38. WCHAR PathName[MAX_PATH];
  39. //
  40. // Open the service control manager database of the local machine.
  41. //
  42. SCMHandle = OpenSCManagerW(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
  43. if (SCMHandle == NULL) {
  44. WStatus = GetLastError();
  45. printf("ERROR: OpenSCManager: WStatus = %d\n", WStatus);
  46. goto EXIT_THE_FUNCTION;
  47. }
  48. WStatus = GetEnvironmentVariableW(L"SystemRoot", PathName, MAX_PATH);
  49. if (WStatus == 0) {
  50. printf("ERROR: GetEnvironmentVariableW: WStatus = %d\n", WStatus);
  51. goto EXIT_THE_FUNCTION;
  52. }
  53. wcscat(PathName, L"\\System32\\davclient.exe");
  54. DavServiceHandle = CreateServiceW(SCMHandle,
  55. L"WebClient",
  56. L"Web Client Network",
  57. SERVICE_ALL_ACCESS,
  58. SERVICE_WIN32_OWN_PROCESS,
  59. SERVICE_DEMAND_START,
  60. SERVICE_ERROR_NORMAL,
  61. PathName,
  62. NULL,
  63. NULL,
  64. NULL,
  65. NULL,
  66. NULL);
  67. if (DavServiceHandle == NULL) {
  68. WStatus = GetLastError();
  69. printf("ERROR: CreateServiceW: WStatus = %d\n", WStatus);
  70. goto EXIT_THE_FUNCTION;
  71. }
  72. EXIT_THE_FUNCTION:
  73. if (SCMHandle) {
  74. CloseServiceHandle(SCMHandle);
  75. }
  76. if (DavServiceHandle) {
  77. CloseServiceHandle(DavServiceHandle);
  78. }
  79. return;
  80. }