home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / delphi / kompon / d56 / MSYSINFO.ZIP / Int / MiTeC_AdvAPI.int < prev    next >
Encoding:
Text File  |  2002-03-01  |  24.8 KB  |  554 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       MiTeC System Information Component              }
  5. {          Windows ADV API Interface Unit               }
  6. {           version 7.3 for Delphi 5,6                  }
  7. {                                                       }
  8. {       Copyright ⌐ 1997,2002 Michal Mutl               }
  9. {                                                       }
  10. {*******************************************************}
  11.  
  12. {$INCLUDE MITEC_DEF.INC}
  13.  
  14. unit MiTeC_AdvAPI;
  15.  
  16. {$ALIGN ON}
  17. {$MINENUMSIZE 4}
  18.  
  19. interface
  20.  
  21. uses Classes, Windows, SysUtils;
  22.  
  23. //
  24. // Constants
  25. //
  26.  
  27. const
  28.  
  29. //
  30. // Service database names
  31. //
  32.   SERVICES_ACTIVE_DATABASEA     = 'ServicesActive';
  33.   SERVICES_ACTIVE_DATABASEW     = 'ServicesActive';
  34.   SERVICES_ACTIVE_DATABASE = SERVICES_ACTIVE_DATABASEA;
  35.   SERVICES_FAILED_DATABASEA     = 'ServicesFailed';
  36.   SERVICES_FAILED_DATABASEW     = 'ServicesFailed';
  37.   SERVICES_FAILED_DATABASE = SERVICES_FAILED_DATABASEA;
  38.  
  39. //
  40. // Character to designate that a name is a group
  41. //
  42.   SC_GROUP_IDENTIFIERA          = '+';
  43.   SC_GROUP_IDENTIFIERW          = '+';
  44.   SC_GROUP_IDENTIFIER = SC_GROUP_IDENTIFIERA;
  45.  
  46. //
  47. // Value to indicate no change to an optional parameter
  48. //
  49.   SERVICE_NO_CHANGE              = $FFFFFFFF;
  50.  
  51. //
  52. // Service State -- for Enum Requests (Bit Mask)
  53. //
  54.   SERVICE_ACTIVE                 = $00000001;
  55.   SERVICE_INACTIVE               = $00000002;
  56.   SERVICE_STATE_ALL              = (SERVICE_ACTIVE   or
  57.                                     SERVICE_INACTIVE);
  58.  
  59. //
  60. // Controls
  61. //
  62.   SERVICE_CONTROL_STOP           = $00000001;
  63.   SERVICE_CONTROL_PAUSE          = $00000002;
  64.   SERVICE_CONTROL_CONTINUE       = $00000003;
  65.   SERVICE_CONTROL_INTERROGATE    = $00000004;
  66.   SERVICE_CONTROL_SHUTDOWN       = $00000005;
  67.  
  68. //
  69. // Service State -- for CurrentState
  70. //
  71.   SERVICE_STOPPED                = $00000001;
  72.   SERVICE_START_PENDING          = $00000002;
  73.   SERVICE_STOP_PENDING           = $00000003;
  74.   SERVICE_RUNNING                = $00000004;
  75.   SERVICE_CONTINUE_PENDING       = $00000005;
  76.   SERVICE_PAUSE_PENDING          = $00000006;
  77.   SERVICE_PAUSED                 = $00000007;
  78.  
  79. //
  80. // Controls Accepted  (Bit Mask)
  81. //
  82.   SERVICE_ACCEPT_STOP            = $00000001;
  83.   SERVICE_ACCEPT_PAUSE_CONTINUE  = $00000002;
  84.   SERVICE_ACCEPT_SHUTDOWN        = $00000004;
  85.  
  86. //
  87. // Service Control Manager object specific access types
  88. //
  89.   SC_MANAGER_CONNECT             = $0001;
  90.   SC_MANAGER_CREATE_SERVICE      = $0002;
  91.   SC_MANAGER_ENUMERATE_SERVICE   = $0004;
  92.   SC_MANAGER_LOCK                = $0008;
  93.   SC_MANAGER_QUERY_LOCK_STATUS   = $0010;
  94.   SC_MANAGER_MODIFY_BOOT_CONFIG  = $0020;
  95.  
  96.   SC_MANAGER_ALL_ACCESS          = (STANDARD_RIGHTS_REQUIRED or
  97.                                     SC_MANAGER_CONNECT or
  98.                                     SC_MANAGER_CREATE_SERVICE or
  99.                                     SC_MANAGER_ENUMERATE_SERVICE or
  100.                                     SC_MANAGER_LOCK or
  101.                                     SC_MANAGER_QUERY_LOCK_STATUS or
  102.                                     SC_MANAGER_MODIFY_BOOT_CONFIG);
  103.  
  104. //
  105. // Service object specific access type
  106. //
  107.   SERVICE_QUERY_CONFIG           = $0001;
  108.   SERVICE_CHANGE_CONFIG          = $0002;
  109.   SERVICE_QUERY_STATUS           = $0004;
  110.   SERVICE_ENUMERATE_DEPENDENTS   = $0008;
  111.   SERVICE_START                  = $0010;
  112.   SERVICE_STOP                   = $0020;
  113.   SERVICE_PAUSE_CONTINUE         = $0040;
  114.   SERVICE_INTERROGATE            = $0080;
  115.   SERVICE_USER_DEFINED_CONTROL   = $0100;
  116.  
  117.   SERVICE_ALL_ACCESS             = (STANDARD_RIGHTS_REQUIRED or
  118.                                     SERVICE_QUERY_CONFIG or
  119.                                     SERVICE_CHANGE_CONFIG or
  120.                                     SERVICE_QUERY_STATUS or
  121.                                     SERVICE_ENUMERATE_DEPENDENTS or
  122.                                     SERVICE_START or
  123.                                     SERVICE_STOP or
  124.                                     SERVICE_PAUSE_CONTINUE or
  125.                                     SERVICE_INTERROGATE or
  126.                                     SERVICE_USER_DEFINED_CONTROL);
  127.  
  128.   SERVICE_KERNEL_DRIVER       = $00000001;
  129.   SERVICE_FILE_SYSTEM_DRIVER  = $00000002;
  130.   SERVICE_ADAPTER             = $00000004;
  131.   SERVICE_RECOGNIZER_DRIVER   = $00000008;
  132.  
  133.   SERVICE_DRIVER              =
  134.     (SERVICE_KERNEL_DRIVER or
  135.      SERVICE_FILE_SYSTEM_DRIVER or
  136.      SERVICE_RECOGNIZER_DRIVER);
  137.  
  138.   SERVICE_WIN32_OWN_PROCESS   = $00000010;
  139.   SERVICE_WIN32_SHARE_PROCESS = $00000020;
  140.   SERVICE_WIN32               =
  141.     (SERVICE_WIN32_OWN_PROCESS or
  142.      SERVICE_WIN32_SHARE_PROCESS);
  143.  
  144.   SERVICE_INTERACTIVE_PROCESS = $00000100;
  145.  
  146.   SERVICE_TYPE_ALL            =
  147.     (SERVICE_WIN32 or
  148.      SERVICE_ADAPTER or
  149.      SERVICE_DRIVER  or
  150.      SERVICE_INTERACTIVE_PROCESS);
  151.  
  152.   SERVICE_BOOT_START = 0;
  153.   SERVICE_SYSTEM_START =1;
  154.   SERVICE_AUTO_START = 2;
  155.   SERVICE_DEMAND_START = 3;
  156.   SERVICE_DISABLED = 4;
  157.  
  158.  
  159. type
  160.  
  161. //
  162. // Handle Types
  163. //
  164.  
  165.   SC_HANDLE = THandle;
  166.   LPSC_HANDLE = ^SC_HANDLE;
  167.  
  168.   SERVICE_STATUS_HANDLE = DWORD;
  169.  
  170. //
  171. // pointer to string pointer
  172. //
  173.  
  174.   PLPSTRA = ^PAnsiChar;
  175.   PLPSTRW = ^PWideChar;
  176.   PLPSTR = PLPSTRA;
  177.  
  178. //
  179. // Service Status Structure
  180. //
  181.  
  182.   PServiceStatus = ^TServiceStatus;
  183.   TServiceStatus = record
  184.     dwServiceType: DWORD;
  185.     dwCurrentState: DWORD;
  186.     dwControlsAccepted: DWORD;
  187.     dwWin32ExitCode: DWORD;
  188.     dwServiceSpecificExitCode: DWORD;
  189.     dwCheckPoint: DWORD;
  190.     dwWaitHint: DWORD;
  191.   end;
  192.  
  193. //
  194. // Service Status Enumeration Structure
  195. //
  196.   PEnumServiceStatusA = ^TEnumServiceStatusA;
  197.   PEnumServiceStatusW = ^TEnumServiceStatusW;
  198.   PEnumServiceStatus = PEnumServiceStatusA;
  199.   TEnumServiceStatusA = record
  200.     lpServiceName: PAnsiChar;
  201.     lpDisplayName: PAnsiChar;
  202.     ServiceStatus: TServiceStatus;
  203.   end;
  204.   TEnumServiceStatusW = record
  205.     lpServiceName: PWideChar;
  206.     lpDisplayName: PWideChar;
  207.     ServiceStatus: TServiceStatus;
  208.   end;
  209.   TEnumServiceStatus = TEnumServiceStatusA;
  210.  
  211. //
  212. // Structures for the Lock API functions
  213. //
  214.   SC_LOCK = Pointer;
  215.   PQueryServiceLockStatusA = ^TQueryServiceLockStatusA;
  216.   PQueryServiceLockStatusW = ^TQueryServiceLockStatusW;
  217.   PQueryServiceLockStatus = PQueryServiceLockStatusA;
  218.   TQueryServiceLockStatusA = record
  219.     fIsLocked: DWORD;
  220.     lpLockOwner: PAnsiChar;
  221.     dwLockDuration: DWORD;
  222.   end;
  223.   TQueryServiceLockStatusW = record
  224.     fIsLocked: DWORD;
  225.     lpLockOwner: PWideChar;
  226.     dwLockDuration: DWORD;
  227.   end;
  228.   TQueryServiceLockStatus = TQueryServiceLockStatusA;
  229.  
  230. //
  231. // Query Service Configuration Structure
  232. //
  233.   PQueryServiceConfigA = ^TQueryServiceConfigA;
  234.   PQueryServiceConfigW = ^TQueryServiceConfigW;
  235.   PQueryServiceConfig = PQueryServiceConfigA;
  236.   TQueryServiceConfigA = record
  237.     dwServiceType: DWORD;
  238.     dwStartType: DWORD;
  239.     dwErrorControl: DWORD;
  240.     lpBinaryPathName: PAnsiChar;
  241.     lpLoadOrderGroup: PAnsiChar;
  242.     dwTagId: DWORD;
  243.     lpDependencies: PAnsiChar;
  244.     lpServiceStartName: PAnsiChar;
  245.     lpDisplayName: PAnsiChar;
  246.   end;
  247.  
  248.   TQueryServiceConfigW = record
  249.     dwServiceType: DWORD;
  250.     dwStartType: DWORD;
  251.     dwErrorControl: DWORD;
  252.     lpBinaryPathName: PWideChar;
  253.     lpLoadOrderGroup: PWideChar;
  254.     dwTagId: DWORD;
  255.     lpDependencies: PWideChar;
  256.     lpServiceStartName: PWideChar;
  257.     lpDisplayName: PWideChar;
  258.   end;
  259.   TQueryServiceConfig = TQueryServiceConfigA;
  260.  
  261. //
  262. // Function Prototype for the Service Main Function
  263. //
  264.  
  265.   TServiceMainFunctionA = TFarProc;
  266.   TServiceMainFunctionW = TFarProc;
  267.   TServiceMainFunction = TServiceMainFunctionA;
  268.  
  269. //
  270. // Service Start Table
  271. //
  272.   PServiceTableEntryA = ^TServiceTableEntryA;
  273.   PServiceTableEntryW = ^TServiceTableEntryW;
  274.   PServiceTableEntry = PServiceTableEntryA;
  275.   TServiceTableEntryA = record
  276.     lpServiceName: PAnsiChar;
  277.     lpServiceProc: TServiceMainFunctionA;
  278.   end;
  279.   TServiceTableEntryW = record
  280.     lpServiceName: PWideChar;
  281.     lpServiceProc: TServiceMainFunctionW;
  282.   end;
  283.   TServiceTableEntry = TServiceTableEntryA;
  284.  
  285.   THandlerFunction = TFarProc;
  286.  
  287.   function InitADVAPI :boolean;
  288.   function FreeADVAPI: Boolean;
  289.   function ChangeServiceConfigA(hService: SC_HANDLE; dwServiceType, dwStartType,
  290.     dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: PAnsiChar;
  291.     lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  292.     lpDisplayName: PAnsiChar): BOOL; stdcall;
  293.   function ChangeServiceConfigW(hService: SC_HANDLE; dwServiceType, dwStartType,
  294.     dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: PWideChar;
  295.     lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  296.     lpDisplayName: PWideChar): BOOL; stdcall;
  297.   function ChangeServiceConfig(hService: SC_HANDLE; dwServiceType, dwStartType,
  298.     dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: PChar;
  299.     lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  300.     lpDisplayName: PChar): BOOL; stdcall;
  301.   function CloseServiceHandle(hSCObject: SC_HANDLE): BOOL; stdcall;
  302.   function ControlService(hService: SC_HANDLE; dwControl: DWORD;
  303.     var lpServiceStatus: TServiceStatus): BOOL; stdcall;
  304.   function CreateServiceA(hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: PAnsiChar;
  305.     dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  306.     lpBinaryPathName, lpLoadOrderGroup: PAnsiChar; lpdwTagId: LPDWORD; lpDependencies,
  307.     lpServiceStartName, lpPassword: PAnsiChar): SC_HANDLE; stdcall;
  308.   function CreateServiceW(hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: PWideChar;
  309.     dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  310.     lpBinaryPathName, lpLoadOrderGroup: PWideChar; lpdwTagId: LPDWORD; lpDependencies,
  311.     lpServiceStartName, lpPassword: PWideChar): SC_HANDLE; stdcall;
  312.   function CreateService(hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: PChar;
  313.     dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  314.     lpBinaryPathName, lpLoadOrderGroup: PChar; lpdwTagId: LPDWORD; lpDependencies,
  315.     lpServiceStartName, lpPassword: PChar): SC_HANDLE; stdcall;
  316.   function DeleteService(hService: SC_HANDLE): BOOL; stdcall;
  317.   function EnumDependentServicesA(hService: SC_HANDLE; dwServiceState: DWORD;
  318.     var lpServices: TEnumServiceStatusA; cbBufSize: DWORD; var pcbBytesNeeded,
  319.     lpServicesReturned : DWORD): BOOL; stdcall;
  320.   function EnumDependentServicesW(hService: SC_HANDLE; dwServiceState: DWORD;
  321.     var lpServices: TEnumServiceStatusW; cbBufSize: DWORD; var pcbBytesNeeded,
  322.     lpServicesReturned : DWORD): BOOL; stdcall;
  323.   function EnumDependentServices(hService: SC_HANDLE; dwServiceState: DWORD;
  324.     var lpServices: TEnumServiceStatus; cbBufSize: DWORD; var pcbBytesNeeded,
  325.     lpServicesReturned : DWORD): BOOL; stdcall;
  326.   function EnumServicesStatusA(hSCManager: SC_HANDLE; dwServiceType,
  327.     dwServiceState: DWORD; var lpServices: TEnumServiceStatusA; cbBufSize: DWORD;
  328.     var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  329.   function EnumServicesStatusW(hSCManager: SC_HANDLE; dwServiceType,
  330.     dwServiceState: DWORD; var lpServices: TEnumServiceStatusW; cbBufSize: DWORD;
  331.     var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  332.   function EnumServicesStatus(hSCManager: SC_HANDLE; dwServiceType,
  333.     dwServiceState: DWORD; var lpServices: TEnumServiceStatus; cbBufSize: DWORD;
  334.     var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  335.   function GetServiceKeyNameA(hSCManager: SC_HANDLE; lpDisplayName,
  336.     lpServiceName: PAnsiChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  337.   function GetServiceKeyNameW(hSCManager: SC_HANDLE; lpDisplayName,
  338.     lpServiceName: PWideChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  339.   function GetServiceKeyName(hSCManager: SC_HANDLE; lpDisplayName,
  340.     lpServiceName: PChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  341.   function GetServiceDisplayNameA(hSCManager: SC_HANDLE; lpServiceName,
  342.     lpDisplayName: PAnsiChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  343.   function GetServiceDisplayNameW(hSCManager: SC_HANDLE; lpServiceName,
  344.     lpDisplayName: PWideChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  345.   function GetServiceDisplayName(hSCManager: SC_HANDLE; lpServiceName,
  346.     lpDisplayName: PChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  347.   function LockServiceDatabase(hSCManager: SC_HANDLE): SC_LOCK; stdcall;
  348.   function NotifyBootConfigStatus(BootAcceptable: BOOL): BOOL; stdcall;
  349.   function OpenSCManagerA(lpMachineName, lpDatabaseName: PAnsiChar;
  350.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  351.   function OpenSCManagerW(lpMachineName, lpDatabaseName: PWideChar;
  352.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  353.   function OpenSCManager(lpMachineName, lpDatabaseName: PChar;
  354.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  355.   function OpenServiceA(hSCManager: SC_HANDLE; lpServiceName: PAnsiChar;
  356.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  357.   function OpenServiceW(hSCManager: SC_HANDLE; lpServiceName: PWideChar;
  358.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  359.   function OpenService(hSCManager: SC_HANDLE; lpServiceName: PChar;
  360.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  361.   function QueryServiceConfigA(hService: SC_HANDLE;
  362.     var lpServiceConfig: TQueryServiceConfigA; cbBufSize: DWORD;
  363.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  364.   function QueryServiceConfigW(hService: SC_HANDLE;
  365.     var lpServiceConfig: TQueryServiceConfigW; cbBufSize: DWORD;
  366.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  367.   function QueryServiceConfig(hService: SC_HANDLE;
  368.     var lpServiceConfig: TQueryServiceConfig; cbBufSize: DWORD;
  369.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  370.   function QueryServiceLockStatusA(hSCManager: SC_HANDLE;
  371.     var lpLockStatus: TQueryServiceLockStatusA; cbBufSize: DWORD;
  372.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  373.   function QueryServiceLockStatusW(hSCManager: SC_HANDLE;
  374.     var lpLockStatus: TQueryServiceLockStatusW; cbBufSize: DWORD;
  375.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  376.   function QueryServiceLockStatus(hSCManager: SC_HANDLE;
  377.     var lpLockStatus: TQueryServiceLockStatus; cbBufSize: DWORD;
  378.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  379.   function QueryServiceObjectSecurity(hService: SC_HANDLE;
  380.     dwSecurityInformation: SECURITY_INFORMATION;
  381.     lpSecurityDescriptor: PSECURITY_DESCRIPTOR; cbBufSize: DWORD;
  382.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  383.   function QueryServiceStatus(hService: SC_HANDLE; var
  384.     lpServiceStatus: TServiceStatus): BOOL; stdcall;
  385.   function RegisterServiceCtrlHandlerA(lpServiceName: PAnsiChar;
  386.     lpHandlerProc: ThandlerFunction): SERVICE_STATUS_HANDLE; stdcall;
  387.   function RegisterServiceCtrlHandlerW(lpServiceName: PWideChar;
  388.     lpHandlerProc: ThandlerFunction): SERVICE_STATUS_HANDLE; stdcall;
  389.   function RegisterServiceCtrlHandler(lpServiceName: PChar;
  390.     lpHandlerProc: ThandlerFunction): SERVICE_STATUS_HANDLE; stdcall;
  391.   function SetServiceObjectSecurity(hService: SC_HANDLE;
  392.     dwSecurityInformation: SECURITY_INFORMATION;
  393.     lpSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  394.   function SetServiceStatus(hServiceStatus: SERVICE_STATUS_HANDLE;
  395.     var lpServiceStatus: TServiceStatus): BOOL; stdcall;
  396.   function StartServiceCtrlDispatcherA(
  397.     var lpServiceStartTable: TServiceTableEntryA): BOOL; stdcall;
  398.   function StartServiceCtrlDispatcherW(
  399.     var lpServiceStartTable: TServiceTableEntryW): BOOL; stdcall;
  400.   function StartServiceCtrlDispatcher(
  401.     var lpServiceStartTable: TServiceTableEntry): BOOL; stdcall;
  402.   function StartServiceA(hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  403.     var lpServiceArgVectors: PAnsiChar): BOOL; stdcall;
  404.   function StartServiceW(hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  405.     var lpServiceArgVectors: PWideChar): BOOL; stdcall;
  406.   function StartService(hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  407.     var lpServiceArgVectors: PChar): BOOL; stdcall;
  408.   function UnlockServiceDatabase(ScLock: SC_LOCK): BOOL; stdcall;
  409.  
  410. type
  411.   TChangeServiceConfigA = function (hService: SC_HANDLE; dwServiceType, dwStartType,
  412.     dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: PAnsiChar;
  413.     lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  414.     lpDisplayName: PAnsiChar): BOOL; stdcall;
  415.   TChangeServiceConfigW = function (hService: SC_HANDLE; dwServiceType, dwStartType,
  416.     dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: PWideChar;
  417.     lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  418.     lpDisplayName: PWideChar): BOOL; stdcall;
  419.   TChangeServiceConfig = function (hService: SC_HANDLE; dwServiceType, dwStartType,
  420.     dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: PChar;
  421.     lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  422.     lpDisplayName: PChar): BOOL; stdcall;
  423.   TCloseServiceHandle = function (hSCObject: SC_HANDLE): BOOL; stdcall;
  424.   TControlService = function (hService: SC_HANDLE; dwControl: DWORD;
  425.     var lpServiceStatus: TServiceStatus): BOOL; stdcall;
  426.   TCreateServiceA = function (hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: PAnsiChar;
  427.     dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  428.     lpBinaryPathName, lpLoadOrderGroup: PAnsiChar; lpdwTagId: LPDWORD; lpDependencies,
  429.     lpServiceStartName, lpPassword: PAnsiChar): SC_HANDLE; stdcall;
  430.   TCreateServiceW = function (hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: PWideChar;
  431.     dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  432.     lpBinaryPathName, lpLoadOrderGroup: PWideChar; lpdwTagId: LPDWORD; lpDependencies,
  433.     lpServiceStartName, lpPassword: PWideChar): SC_HANDLE; stdcall;
  434.   TCreateService = function (hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: PChar;
  435.     dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  436.     lpBinaryPathName, lpLoadOrderGroup: PChar; lpdwTagId: LPDWORD; lpDependencies,
  437.     lpServiceStartName, lpPassword: PChar): SC_HANDLE; stdcall;
  438.   TDeleteService = function (hService: SC_HANDLE): BOOL; stdcall;
  439.   TEnumDependentServicesA = function (hService: SC_HANDLE; dwServiceState: DWORD;
  440.     var lpServices: TEnumServiceStatusA; cbBufSize: DWORD; var pcbBytesNeeded,
  441.     lpServicesReturned : DWORD): BOOL; stdcall;
  442.   TEnumDependentServicesW = function (hService: SC_HANDLE; dwServiceState: DWORD;
  443.     var lpServices: TEnumServiceStatusW; cbBufSize: DWORD; var pcbBytesNeeded,
  444.     lpServicesReturned : DWORD): BOOL; stdcall;
  445.   TEnumDependentServices = function (hService: SC_HANDLE; dwServiceState: DWORD;
  446.     var lpServices: TEnumServiceStatus; cbBufSize: DWORD; var pcbBytesNeeded,
  447.     lpServicesReturned : DWORD): BOOL; stdcall;
  448.   TEnumServicesStatusA = function (hSCManager: SC_HANDLE; dwServiceType,
  449.     dwServiceState: DWORD; var lpServices: TEnumServiceStatusA; cbBufSize: DWORD;
  450.     var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  451.   TEnumServicesStatusW = function (hSCManager: SC_HANDLE; dwServiceType,
  452.     dwServiceState: DWORD; var lpServices: TEnumServiceStatusW; cbBufSize: DWORD;
  453.     var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  454.   TEnumServicesStatus = function (hSCManager: SC_HANDLE; dwServiceType,
  455.     dwServiceState: DWORD; var lpServices: TEnumServiceStatus; cbBufSize: DWORD;
  456.     var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  457.   TGetServiceKeyNameA = function (hSCManager: SC_HANDLE; lpDisplayName,
  458.     lpServiceName: PAnsiChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  459.   TGetServiceKeyNameW = function (hSCManager: SC_HANDLE; lpDisplayName,
  460.     lpServiceName: PWideChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  461.   TGetServiceKeyName = function (hSCManager: SC_HANDLE; lpDisplayName,
  462.     lpServiceName: PChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  463.   TGetServiceDisplayNameA = function (hSCManager: SC_HANDLE; lpServiceName,
  464.     lpDisplayName: PAnsiChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  465.   TGetServiceDisplayNameW = function (hSCManager: SC_HANDLE; lpServiceName,
  466.     lpDisplayName: PWideChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  467.   TGetServiceDisplayName = function (hSCManager: SC_HANDLE; lpServiceName,
  468.     lpDisplayName: PChar; var lpcchBuffer: DWORD): BOOL; stdcall;
  469.   TLockServiceDatabase = function (hSCManager: SC_HANDLE): SC_LOCK; stdcall;
  470.   TNotifyBootConfigStatus = function (BootAcceptable: BOOL): BOOL; stdcall;
  471.   TOpenSCManagerA = function (lpMachineName, lpDatabaseName: PAnsiChar;
  472.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  473.   TOpenSCManagerW = function (lpMachineName, lpDatabaseName: PWideChar;
  474.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  475.   TOpenSCManager = function (lpMachineName, lpDatabaseName: PChar;
  476.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  477.   TOpenServiceA = function (hSCManager: SC_HANDLE; lpServiceName: PAnsiChar;
  478.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  479.   TOpenServiceW = function (hSCManager: SC_HANDLE; lpServiceName: PWideChar;
  480.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  481.   TOpenService = function (hSCManager: SC_HANDLE; lpServiceName: PChar;
  482.     dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  483.   TfQueryServiceConfigA = function (hService: SC_HANDLE;
  484.     var lpServiceConfig: TQueryServiceConfigA; cbBufSize: DWORD;
  485.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  486.   TfQueryServiceConfigW = function (hService: SC_HANDLE;
  487.     var lpServiceConfig: TQueryServiceConfigW; cbBufSize: DWORD;
  488.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  489.   TfQueryServiceConfig = function (hService: SC_HANDLE;
  490.     var lpServiceConfig: TQueryServiceConfig; cbBufSize: DWORD;
  491.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  492.   TfQueryServiceLockStatusA = function (hSCManager: SC_HANDLE;
  493.     var lpLockStatus: TQueryServiceLockStatusA; cbBufSize: DWORD;
  494.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  495.   TfQueryServiceLockStatusW = function (hSCManager: SC_HANDLE;
  496.     var lpLockStatus: TQueryServiceLockStatusW; cbBufSize: DWORD;
  497.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  498.   TfQueryServiceLockStatus = function (hSCManager: SC_HANDLE;
  499.     var lpLockStatus: TQueryServiceLockStatus; cbBufSize: DWORD;
  500.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  501.   TQueryServiceObjectSecurity = function (hService: SC_HANDLE;
  502.     dwSecurityInformation: SECURITY_INFORMATION;
  503.     lpSecurityDescriptor: PSECURITY_DESCRIPTOR; cbBufSize: DWORD;
  504.     var pcbBytesNeeded: DWORD): BOOL; stdcall;
  505.   TQueryServiceStatus = function (hService: SC_HANDLE; var
  506.     lpServiceStatus: TServiceStatus): BOOL; stdcall;
  507.   TRegisterServiceCtrlHandlerA = function (lpServiceName: PAnsiChar;
  508.     lpHandlerProc: ThandlerFunction): SERVICE_STATUS_HANDLE; stdcall;
  509.   TRegisterServiceCtrlHandlerW = function (lpServiceName: PWideChar;
  510.     lpHandlerProc: ThandlerFunction): SERVICE_STATUS_HANDLE; stdcall;
  511.   TRegisterServiceCtrlHandler = function (lpServiceName: PChar;
  512.     lpHandlerProc: ThandlerFunction): SERVICE_STATUS_HANDLE; stdcall;
  513.   TSetServiceObjectSecurity = function (hService: SC_HANDLE;
  514.     dwSecurityInformation: SECURITY_INFORMATION;
  515.     lpSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  516.   TSetServiceStatus = function (hServiceStatus: SERVICE_STATUS_HANDLE;
  517.     var lpServiceStatus: TServiceStatus): BOOL; stdcall;
  518.   TStartServiceCtrlDispatcherA = function (
  519.     var lpServiceStartTable: TServiceTableEntryA): BOOL; stdcall;
  520.   TStartServiceCtrlDispatcherW = function (
  521.     var lpServiceStartTable: TServiceTableEntryW): BOOL; stdcall;
  522.   TStartServiceCtrlDispatcher = function (
  523.     var lpServiceStartTable: TServiceTableEntry): BOOL; stdcall;
  524.   TStartServiceA = function (hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  525.     var lpServiceArgVectors: PAnsiChar): BOOL; stdcall;
  526.   TStartServiceW = function (hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  527.     var lpServiceArgVectors: PWideChar): BOOL; stdcall;
  528.   TStartService = function (hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  529.     var lpServiceArgVectors: PChar): BOOL; stdcall;
  530.   TUnlockServiceDatabase = function (ScLock: SC_LOCK): BOOL; stdcall;
  531.  
  532. function ServiceGetErrCtrlStr(nID :integer) :string;
  533. function ServiceGetStatStr(nID :integer) :string;
  534. function ServiceGetStartStr(nID :integer) :string;
  535. function ServiceGetTypeStr(nID :integer) :string;
  536.  
  537. function ServiceGetStatus(sMachine,sService :string ) :DWord;
  538. function ServiceRunning(sMachine,sService :string ) :boolean;
  539. function ServiceStopped(sMachine,sService :string ) :boolean;
  540. function ServiceStart(sMachine,sService,sArgs :string ) :boolean;
  541. function ServiceStop(sMachine,sService :string ) :boolean;
  542. function ServicePause(sMachine,sService :string ) :boolean;
  543. function ServiceContinue(sMachine,sService :string ) :Boolean;
  544. function ServiceGetKeyName(sMachine,sServiceDispName :string ) :string;
  545. function ServiceGetDisplayName(sMachine,sServiceKeyName :string ) :string;
  546.  
  547. function ServiceGetList(sMachine :string; dwServiceType,dwServiceState :DWord; slServicesList :TStrings ) :boolean;
  548. function ServiceGetConfig(sMachine,sService :string; var QSC: TQueryServiceConfig) :boolean;
  549.  
  550. implementation
  551.  
  552.  
  553.  
  554.