JwaWinSvc.pas
上传用户:davidchvip
上传日期:2009-07-28
资源大小:1749k
文件大小:72k
源码类别:

Windows编程

开发平台:

Delphi

  1. {******************************************************************************}
  2. {                                                                       }
  3. { Services API interface Unit for Object Pascal                                }
  4. {                                                                       }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
  6. { Corporation. All Rights Reserved.                                            }
  7. {                 }
  8. { The original file is: winsvc.h, released June 2000. The original Pascal      }
  9. { code is: WinSvc.pas, released December 2000. The initial developer of the    }
  10. { Pascal code is Marcel van Brakel (brakelm@chello.nl).                        }
  11. {                                                                              }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
  13. { Marcel van Brakel. All Rights Reserved.                                      }
  14. {                 }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
  16. {                }
  17. { You may retrieve the latest version of this file at the Project JEDI home    }
  18. { page, located at http://delphi-jedi.org or my personal homepage located at   }
  19. { http://members.chello.nl/m.vanbrakel2                                        }
  20. {                }
  21. { The contents of this file are used with permission, subject to the Mozilla   }
  22. { Public License Version 1.1 (the "License"); you may not use this file except }
  23. { in compliance with the License. You may obtain a copy of the License at      }
  24. { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
  25. {                                                                              }
  26. { Software distributed under the License is distributed on an "AS IS" basis,   }
  27. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  28. { the specific language governing rights and limitations under the License.    }
  29. {                                                                              }
  30. { Alternatively, the contents of this file may be used under the terms of the  }
  31. { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
  32. { provisions of the LGPL License are applicable instead of those above.        }
  33. { If you wish to allow use of your version of this file only under the terms   }
  34. { of the LGPL License and not to allow others to use your version of this file }
  35. { under the MPL, indicate your decision by deleting  the provisions above and  }
  36. { replace  them with the notice and other provisions required by the LGPL      }
  37. { License.  If you do not delete the provisions above, a recipient may use     }
  38. { your version of this file under either the MPL or the LGPL License.          }
  39. {                 }
  40. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  41. {                 }
  42. {******************************************************************************}
  43. unit JwaWinSvc;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "WinSvc.h"'}
  47. {$HPPEMIT ''}
  48. {$I WINDEFINES.INC}
  49. interface
  50. uses
  51.   JwaWinNT, JwaWinType;
  52. //
  53. // Service database names
  54. //
  55. const
  56.   SERVICES_ACTIVE_DATABASEW = 'ServicesActive';
  57.   {$EXTERNALSYM SERVICES_ACTIVE_DATABASEW}
  58.   SERVICES_FAILED_DATABASEW = 'ServicesFailed';
  59.   {$EXTERNALSYM SERVICES_FAILED_DATABASEW}
  60.   SERVICES_ACTIVE_DATABASEA = 'ServicesActive';
  61.   {$EXTERNALSYM SERVICES_ACTIVE_DATABASEA}
  62.   SERVICES_FAILED_DATABASEA = 'ServicesFailed';
  63.   {$EXTERNALSYM SERVICES_FAILED_DATABASEA}
  64. //
  65. // Character to designate that a name is a group
  66. //
  67.   SC_GROUP_IDENTIFIERW = '+';
  68.   {$EXTERNALSYM SC_GROUP_IDENTIFIERW}
  69.   SC_GROUP_IDENTIFIERA = '+';
  70.   {$EXTERNALSYM SC_GROUP_IDENTIFIERA}
  71. {$IFDEF UNICODE}
  72.   SERVICES_ACTIVE_DATABASE = SERVICES_ACTIVE_DATABASEW;
  73.   {$EXTERNALSYM SERVICES_ACTIVE_DATABASE}
  74.   SERVICES_FAILED_DATABASE = SERVICES_FAILED_DATABASEW;
  75.   {$EXTERNALSYM SERVICES_FAILED_DATABASE}
  76.   SC_GROUP_IDENTIFIER = SC_GROUP_IDENTIFIERW;
  77.   {$EXTERNALSYM SC_GROUP_IDENTIFIER}
  78. {$ELSE}
  79.   SERVICES_ACTIVE_DATABASE = SERVICES_ACTIVE_DATABASEA;
  80.   {$EXTERNALSYM SERVICES_ACTIVE_DATABASE}
  81.   SERVICES_FAILED_DATABASE = SERVICES_FAILED_DATABASEA;
  82.   {$EXTERNALSYM SERVICES_FAILED_DATABASE}
  83.   SC_GROUP_IDENTIFIER = SC_GROUP_IDENTIFIERA;
  84.   {$EXTERNALSYM SC_GROUP_IDENTIFIER}
  85. {$ENDIF}
  86. //
  87. // Value to indicate no change to an optional parameter
  88. //
  89.   SERVICE_NO_CHANGE = $ffffffff;
  90.   {$EXTERNALSYM SERVICE_NO_CHANGE}
  91. //
  92. // Service State -- for Enum Requests (Bit Mask)
  93. //
  94.   SERVICE_ACTIVE    = $00000001;
  95.   {$EXTERNALSYM SERVICE_ACTIVE}
  96.   SERVICE_INACTIVE  = $00000002;
  97.   {$EXTERNALSYM SERVICE_INACTIVE}
  98.   SERVICE_STATE_ALL = SERVICE_ACTIVE or SERVICE_INACTIVE;
  99.   {$EXTERNALSYM SERVICE_STATE_ALL}
  100. //
  101. // Controls
  102. //
  103.   SERVICE_CONTROL_STOP                  = $00000001;
  104.   {$EXTERNALSYM SERVICE_CONTROL_STOP}
  105.   SERVICE_CONTROL_PAUSE                 = $00000002;
  106.   {$EXTERNALSYM SERVICE_CONTROL_PAUSE}
  107.   SERVICE_CONTROL_CONTINUE              = $00000003;
  108.   {$EXTERNALSYM SERVICE_CONTROL_CONTINUE}
  109.   SERVICE_CONTROL_INTERROGATE           = $00000004;
  110.   {$EXTERNALSYM SERVICE_CONTROL_INTERROGATE}
  111.   SERVICE_CONTROL_SHUTDOWN              = $00000005;
  112.   {$EXTERNALSYM SERVICE_CONTROL_SHUTDOWN}
  113.   SERVICE_CONTROL_PARAMCHANGE           = $00000006;
  114.   {$EXTERNALSYM SERVICE_CONTROL_PARAMCHANGE}
  115.   SERVICE_CONTROL_NETBINDADD            = $00000007;
  116.   {$EXTERNALSYM SERVICE_CONTROL_NETBINDADD}
  117.   SERVICE_CONTROL_NETBINDREMOVE         = $00000008;
  118.   {$EXTERNALSYM SERVICE_CONTROL_NETBINDREMOVE}
  119.   SERVICE_CONTROL_NETBINDENABLE         = $00000009;
  120.   {$EXTERNALSYM SERVICE_CONTROL_NETBINDENABLE}
  121.   SERVICE_CONTROL_NETBINDDISABLE        = $0000000A;
  122.   {$EXTERNALSYM SERVICE_CONTROL_NETBINDDISABLE}
  123.   SERVICE_CONTROL_DEVICEEVENT           = $0000000B;
  124.   {$EXTERNALSYM SERVICE_CONTROL_DEVICEEVENT}
  125.   SERVICE_CONTROL_HARDWAREPROFILECHANGE = $0000000C;
  126.   {$EXTERNALSYM SERVICE_CONTROL_HARDWAREPROFILECHANGE}
  127.   SERVICE_CONTROL_POWEREVENT            = $0000000D;
  128.   {$EXTERNALSYM SERVICE_CONTROL_POWEREVENT}
  129.   SERVICE_CONTROL_SESSIONCHANGE         = $0000000E;
  130.   {$EXTERNALSYM SERVICE_CONTROL_SESSIONCHANGE}
  131. //
  132. // Service State -- for CurrentState
  133. //
  134.   SERVICE_STOPPED          = $00000001;
  135.   {$EXTERNALSYM SERVICE_STOPPED}
  136.   SERVICE_START_PENDING    = $00000002;
  137.   {$EXTERNALSYM SERVICE_START_PENDING}
  138.   SERVICE_STOP_PENDING     = $00000003;
  139.   {$EXTERNALSYM SERVICE_STOP_PENDING}
  140.   SERVICE_RUNNING          = $00000004;
  141.   {$EXTERNALSYM SERVICE_RUNNING}
  142.   SERVICE_CONTINUE_PENDING = $00000005;
  143.   {$EXTERNALSYM SERVICE_CONTINUE_PENDING}
  144.   SERVICE_PAUSE_PENDING    = $00000006;
  145.   {$EXTERNALSYM SERVICE_PAUSE_PENDING}
  146.   SERVICE_PAUSED           = $00000007;
  147.   {$EXTERNALSYM SERVICE_PAUSED}
  148. //
  149. // Controls Accepted  (Bit Mask)
  150. //
  151.   SERVICE_ACCEPT_STOP                  = $00000001;
  152.   {$EXTERNALSYM SERVICE_ACCEPT_STOP}
  153.   SERVICE_ACCEPT_PAUSE_CONTINUE        = $00000002;
  154.   {$EXTERNALSYM SERVICE_ACCEPT_PAUSE_CONTINUE}
  155.   SERVICE_ACCEPT_SHUTDOWN              = $00000004;
  156.   {$EXTERNALSYM SERVICE_ACCEPT_SHUTDOWN}
  157.   SERVICE_ACCEPT_PARAMCHANGE           = $00000008;
  158.   {$EXTERNALSYM SERVICE_ACCEPT_PARAMCHANGE}
  159.   SERVICE_ACCEPT_NETBINDCHANGE         = $00000010;
  160.   {$EXTERNALSYM SERVICE_ACCEPT_NETBINDCHANGE}
  161.   SERVICE_ACCEPT_HARDWAREPROFILECHANGE = $00000020;
  162.   {$EXTERNALSYM SERVICE_ACCEPT_HARDWAREPROFILECHANGE}
  163.   SERVICE_ACCEPT_POWEREVENT            = $00000040;
  164.   {$EXTERNALSYM SERVICE_ACCEPT_POWEREVENT}
  165.   SERVICE_ACCEPT_SESSIONCHANGE         = $00000080;
  166.   {$EXTERNALSYM SERVICE_ACCEPT_SESSIONCHANGE}
  167. //
  168. // Service Control Manager object specific access types
  169. //
  170.   SC_MANAGER_CONNECT            = $0001;
  171.   {$EXTERNALSYM SC_MANAGER_CONNECT}
  172.   SC_MANAGER_CREATE_SERVICE     = $0002;
  173.   {$EXTERNALSYM SC_MANAGER_CREATE_SERVICE}
  174.   SC_MANAGER_ENUMERATE_SERVICE  = $0004;
  175.   {$EXTERNALSYM SC_MANAGER_ENUMERATE_SERVICE}
  176.   SC_MANAGER_LOCK               = $0008;
  177.   {$EXTERNALSYM SC_MANAGER_LOCK}
  178.   SC_MANAGER_QUERY_LOCK_STATUS  = $0010;
  179.   {$EXTERNALSYM SC_MANAGER_QUERY_LOCK_STATUS}
  180.   SC_MANAGER_MODIFY_BOOT_CONFIG = $0020;
  181.   {$EXTERNALSYM SC_MANAGER_MODIFY_BOOT_CONFIG}
  182.   SC_MANAGER_ALL_ACCESS         = STANDARD_RIGHTS_REQUIRED or
  183.                                   SC_MANAGER_CONNECT or
  184.                                   SC_MANAGER_CREATE_SERVICE or
  185.                                   SC_MANAGER_ENUMERATE_SERVICE or
  186.                                   SC_MANAGER_LOCK or
  187.                                   SC_MANAGER_QUERY_LOCK_STATUS or
  188.                                   SC_MANAGER_MODIFY_BOOT_CONFIG;
  189.   {$EXTERNALSYM SC_MANAGER_ALL_ACCESS}
  190. //
  191. // Service object specific access type
  192. //
  193.   SERVICE_QUERY_CONFIG         = $0001;
  194.   {$EXTERNALSYM SERVICE_QUERY_CONFIG}
  195.   SERVICE_CHANGE_CONFIG        = $0002;
  196.   {$EXTERNALSYM SERVICE_CHANGE_CONFIG}
  197.   SERVICE_QUERY_STATUS         = $0004;
  198.   {$EXTERNALSYM SERVICE_QUERY_STATUS}
  199.   SERVICE_ENUMERATE_DEPENDENTS = $0008;
  200.   {$EXTERNALSYM SERVICE_ENUMERATE_DEPENDENTS}
  201.   SERVICE_START                = $0010;
  202.   {$EXTERNALSYM SERVICE_START}
  203.   SERVICE_STOP                 = $0020;
  204.   {$EXTERNALSYM SERVICE_STOP}
  205.   SERVICE_PAUSE_CONTINUE       = $0040;
  206.   {$EXTERNALSYM SERVICE_PAUSE_CONTINUE}
  207.   SERVICE_INTERROGATE          = $0080;
  208.   {$EXTERNALSYM SERVICE_INTERROGATE}
  209.   SERVICE_USER_DEFINED_CONTROL = $0100;
  210.   {$EXTERNALSYM SERVICE_USER_DEFINED_CONTROL}
  211.   SERVICE_ALL_ACCESS           = STANDARD_RIGHTS_REQUIRED or
  212.                                  SERVICE_QUERY_CONFIG or
  213.                                  SERVICE_CHANGE_CONFIG or
  214.                                  SERVICE_QUERY_STATUS or
  215.                                  SERVICE_ENUMERATE_DEPENDENTS or
  216.                                  SERVICE_START or
  217.                                  SERVICE_STOP or
  218.                                  SERVICE_PAUSE_CONTINUE or
  219.                                  SERVICE_INTERROGATE or
  220.                                  SERVICE_USER_DEFINED_CONTROL;
  221.   {$EXTERNALSYM SERVICE_ALL_ACCESS}
  222. //
  223. // Service flags for QueryServiceStatusEx
  224. //
  225.   SERVICE_RUNS_IN_SYSTEM_PROCESS = $00000001;
  226.   {$EXTERNALSYM SERVICE_RUNS_IN_SYSTEM_PROCESS}
  227. //
  228. // Info levels for ChangeServiceConfig2 and QueryServiceConfig2
  229. //
  230.   SERVICE_CONFIG_DESCRIPTION     = 1;
  231.   {$EXTERNALSYM SERVICE_CONFIG_DESCRIPTION}
  232.   SERVICE_CONFIG_FAILURE_ACTIONS = 2;
  233.   {$EXTERNALSYM SERVICE_CONFIG_FAILURE_ACTIONS}
  234. //
  235. // Service description string
  236. //
  237. type
  238.   LPSERVICE_DESCRIPTIONA = ^SERVICE_DESCRIPTIONA;
  239.   {$EXTERNALSYM LPSERVICE_DESCRIPTIONA}
  240.   _SERVICE_DESCRIPTIONA = record
  241.     lpDescription: LPSTR;
  242.   end;
  243.   {$EXTERNALSYM _SERVICE_DESCRIPTIONA}
  244.   SERVICE_DESCRIPTIONA = _SERVICE_DESCRIPTIONA;
  245.   {$EXTERNALSYM SERVICE_DESCRIPTIONA}
  246.   TServiceDescriptionA = SERVICE_DESCRIPTIONA;
  247.   PServiceDescriptionA = LPSERVICE_DESCRIPTIONA;
  248. //
  249. // Service description string
  250. //
  251.   LPSERVICE_DESCRIPTIONW = ^SERVICE_DESCRIPTIONW;
  252.   {$EXTERNALSYM LPSERVICE_DESCRIPTIONW}
  253.   _SERVICE_DESCRIPTIONW = record
  254.     lpDescription: LPWSTR;
  255.   end;
  256.   {$EXTERNALSYM _SERVICE_DESCRIPTIONW}
  257.   SERVICE_DESCRIPTIONW = _SERVICE_DESCRIPTIONW;
  258.   {$EXTERNALSYM SERVICE_DESCRIPTIONW}
  259.   TServiceDescriptionW = SERVICE_DESCRIPTIONW;
  260.   PServiceDescriptionW = LPSERVICE_DESCRIPTIONW;
  261. {$IFDEF UNICODE}
  262.   SERVICE_DESCRIPTION = SERVICE_DESCRIPTIONW;
  263.   {$EXTERNALSYM SERVICE_DESCRIPTION}
  264.   LPSERVICE_DESCRIPTION = LPSERVICE_DESCRIPTIONW;
  265.   {$EXTERNALSYM LPSERVICE_DESCRIPTION}
  266.   TServiceDescription = TServiceDescriptionW;
  267.   PServiceDescription = PServiceDescriptionW;
  268. {$ELSE}
  269.   SERVICE_DESCRIPTION = SERVICE_DESCRIPTIONA;
  270.   {$EXTERNALSYM SERVICE_DESCRIPTION}
  271.   LPSERVICE_DESCRIPTION = LPSERVICE_DESCRIPTIONA;
  272.   {$EXTERNALSYM LPSERVICE_DESCRIPTION}
  273.   TServiceDescription = TServiceDescriptionA;
  274.   PServiceDescription = PServiceDescriptionA;
  275. {$ENDIF}
  276. //
  277. // Actions to take on service failure
  278. //
  279.   _SC_ACTION_TYPE = (SC_ACTION_NONE, SC_ACTION_RESTART, SC_ACTION_REBOOT,
  280.     SC_ACTION_RUN_COMMAND);
  281.   {$EXTERNALSYM _SC_ACTION_TYPE}
  282.   SC_ACTION_TYPE = _SC_ACTION_TYPE;
  283.   {$EXTERNALSYM SC_ACTION_TYPE}
  284.   TScActionType = _SC_ACTION_TYPE;
  285.   LPSC_ACTION = ^SC_ACTION;
  286.   {$EXTERNALSYM LPSC_ACTION}
  287.   _SC_ACTION = record
  288.     Type_: SC_ACTION_TYPE;
  289.     Delay: DWORD;
  290.   end;
  291.   {$EXTERNALSYM _SC_ACTION}
  292.   SC_ACTION = _SC_ACTION;
  293.   {$EXTERNALSYM SC_ACTION}
  294.   TScAction = SC_ACTION;
  295.   PScAction = LPSC_ACTION;
  296.   LPSERVICE_FAILURE_ACTIONSA = ^SERVICE_FAILURE_ACTIONSA;
  297.   {$EXTERNALSYM LPSERVICE_FAILURE_ACTIONSA}
  298.   _SERVICE_FAILURE_ACTIONSA = record
  299.     dwResetPeriod: DWORD;
  300.     lpRebootMsg: LPSTR;
  301.     lpCommand: LPSTR;
  302.     cActions: DWORD;
  303.     lpsaActions: LPSC_ACTION;
  304.   end;
  305.   {$EXTERNALSYM _SERVICE_FAILURE_ACTIONSA}
  306.   SERVICE_FAILURE_ACTIONSA = _SERVICE_FAILURE_ACTIONSA;
  307.   {$EXTERNALSYM SERVICE_FAILURE_ACTIONSA}
  308.   TServiceFailureActionsA = SERVICE_FAILURE_ACTIONSA;
  309.   PServiceFailureActionsA = LPSERVICE_FAILURE_ACTIONSA;
  310.   LPSERVICE_FAILURE_ACTIONSW = ^SERVICE_FAILURE_ACTIONSW;
  311.   {$EXTERNALSYM LPSERVICE_FAILURE_ACTIONSW}
  312.   _SERVICE_FAILURE_ACTIONSW = record
  313.     dwResetPeriod: DWORD;
  314.     lpRebootMsg: LPWSTR;
  315.     lpCommand: LPWSTR;
  316.     cActions: DWORD;
  317.     lpsaActions: LPSC_ACTION;
  318.   end;
  319.   {$EXTERNALSYM _SERVICE_FAILURE_ACTIONSW}
  320.   SERVICE_FAILURE_ACTIONSW = _SERVICE_FAILURE_ACTIONSW;
  321.   {$EXTERNALSYM SERVICE_FAILURE_ACTIONSW}
  322.   TServiceFailureActionsW = SERVICE_FAILURE_ACTIONSW;
  323.   PServiceFailureActionsW = LPSERVICE_FAILURE_ACTIONSW;
  324. {$IFDEF UNICODE}
  325.   SERVICE_FAILURE_ACTIONS = SERVICE_FAILURE_ACTIONSW;
  326.   {$EXTERNALSYM SERVICE_FAILURE_ACTIONS}
  327.   LPSERVICE_FAILURE_ACTIONS = LPSERVICE_FAILURE_ACTIONSW;
  328.   {$EXTERNALSYM LPSERVICE_FAILURE_ACTIONS}
  329.   TServiceFailureActions = TServiceFailureActionsW;
  330.   PServiceFailureActions = PServiceFailureActionsW;
  331. {$ELSE}
  332.   SERVICE_FAILURE_ACTIONS = SERVICE_FAILURE_ACTIONSA;
  333.   {$EXTERNALSYM SERVICE_FAILURE_ACTIONS}
  334.   LPSERVICE_FAILURE_ACTIONS = LPSERVICE_FAILURE_ACTIONSA;
  335.   {$EXTERNALSYM LPSERVICE_FAILURE_ACTIONS}
  336.   TServiceFailureActions = TServiceFailureActionsA;
  337.   PServiceFailureActions = PServiceFailureActionsA;
  338. {$ENDIF}
  339. //
  340. // Handle Types
  341. //
  342.   SC_HANDLE = HANDLE;
  343.   {$EXTERNALSYM SC_HANDLE}
  344.   LPSC_HANDLE = ^SC_HANDLE;
  345.   {$EXTERNALSYM LPSC_HANDLE}
  346.   SERVICE_STATUS_HANDLE = HANDLE;
  347.   {$EXTERNALSYM SERVICE_STATUS_HANDLE}
  348. //
  349. // Info levels for QueryServiceStatusEx
  350. //
  351.   _SC_STATUS_TYPE = (SC_STATUS_PROCESS_INFO);
  352.   {$EXTERNALSYM _SC_STATUS_TYPE}
  353.   SC_STATUS_TYPE = _SC_STATUS_TYPE;
  354.   {$EXTERNALSYM SC_STATUS_TYPE}
  355. //
  356. // Info levels for EnumServicesStatusEx
  357. //
  358.   _SC_ENUM_TYPE = (SC_ENUM_PROCESS_INFO);
  359.   {$EXTERNALSYM _SC_ENUM_TYPE}
  360.   SC_ENUM_TYPE = _SC_ENUM_TYPE;
  361.   {$EXTERNALSYM SC_ENUM_TYPE}
  362. //
  363. // Service Status Structures
  364. //
  365.   LPSERVICE_STATUS = ^SERVICE_STATUS;
  366.   {$EXTERNALSYM LPSERVICE_STATUS}
  367.   _SERVICE_STATUS = record
  368.     dwServiceType: DWORD;
  369.     dwCurrentState: DWORD;
  370.     dwControlsAccepted: DWORD;
  371.     dwWin32ExitCode: DWORD;
  372.     dwServiceSpecificExitCode: DWORD;
  373.     dwCheckPoint: DWORD;
  374.     dwWaitHint: DWORD;
  375.   end;
  376.   {$EXTERNALSYM _SERVICE_STATUS}
  377.   SERVICE_STATUS = _SERVICE_STATUS;
  378.   {$EXTERNALSYM SERVICE_STATUS}
  379.   TServiceStatus = SERVICE_STATUS;
  380.   PServiceStatus = LPSERVICE_STATUS;
  381.   LPSERVICE_STATUS_PROCESS = ^SERVICE_STATUS_PROCESS;
  382.   {$EXTERNALSYM LPSERVICE_STATUS_PROCESS}
  383.   _SERVICE_STATUS_PROCESS = record
  384.     dwServiceType: DWORD;
  385.     dwCurrentState: DWORD;
  386.     dwControlsAccepted: DWORD;
  387.     dwWin32ExitCode: DWORD;
  388.     dwServiceSpecificExitCode: DWORD;
  389.     dwCheckPoint: DWORD;
  390.     dwWaitHint: DWORD;
  391.     dwProcessId: DWORD;
  392.     dwServiceFlags: DWORD;
  393.   end;
  394.   {$EXTERNALSYM _SERVICE_STATUS_PROCESS}
  395.   SERVICE_STATUS_PROCESS = _SERVICE_STATUS_PROCESS;
  396.   {$EXTERNALSYM SERVICE_STATUS_PROCESS}
  397.   TServiceStatusProcess = SERVICE_STATUS_PROCESS;
  398.   PServiceStatusProcess = LPSERVICE_STATUS_PROCESS;
  399. //
  400. // Service Status Enumeration Structure
  401. //
  402.   LPENUM_SERVICE_STATUSA = ^ENUM_SERVICE_STATUSA;
  403.   {$EXTERNALSYM LPENUM_SERVICE_STATUSA}
  404.   _ENUM_SERVICE_STATUSA = record
  405.     lpServiceName: LPSTR;
  406.     lpDisplayName: LPSTR;
  407.     ServiceStatus: SERVICE_STATUS;
  408.   end;
  409.   {$EXTERNALSYM _ENUM_SERVICE_STATUSA}
  410.   ENUM_SERVICE_STATUSA = _ENUM_SERVICE_STATUSA;
  411.   {$EXTERNALSYM ENUM_SERVICE_STATUSA}
  412.   TEnumServiceStatusA = ENUM_SERVICE_STATUSA;
  413.   PEnumServiceStatusA = LPENUM_SERVICE_STATUSA;
  414.   LPENUM_SERVICE_STATUSW = ^ENUM_SERVICE_STATUSW;
  415.   {$EXTERNALSYM LPENUM_SERVICE_STATUSW}
  416.   _ENUM_SERVICE_STATUSW = record
  417.     lpServiceName: LPWSTR;
  418.     lpDisplayName: LPWSTR;
  419.     ServiceStatus: SERVICE_STATUS;
  420.   end;
  421.   {$EXTERNALSYM _ENUM_SERVICE_STATUSW}
  422.   ENUM_SERVICE_STATUSW = _ENUM_SERVICE_STATUSW;
  423.   {$EXTERNALSYM ENUM_SERVICE_STATUSW}
  424.   TEnumServiceStatusW = ENUM_SERVICE_STATUSW;
  425.   PEnumServiceStatusW = LPENUM_SERVICE_STATUSW;
  426. {$IFDEF UNICODE}
  427.   ENUM_SERVICE_STATUS = ENUM_SERVICE_STATUSW;
  428.   {$EXTERNALSYM ENUM_SERVICE_STATUS}
  429.   LPENUM_SERVICE_STATUS = LPENUM_SERVICE_STATUSW;
  430.   {$EXTERNALSYM LPENUM_SERVICE_STATUS}
  431.   TEnumServiceStatus = TEnumServiceStatusW;
  432.   PEnumServiceStatus = PEnumServiceStatusW;
  433. {$ELSE}
  434.   ENUM_SERVICE_STATUS = ENUM_SERVICE_STATUSA;
  435.   {$EXTERNALSYM ENUM_SERVICE_STATUS}
  436.   LPENUM_SERVICE_STATUS = LPENUM_SERVICE_STATUSA;
  437.   {$EXTERNALSYM LPENUM_SERVICE_STATUS}
  438.   TEnumServiceStatus = TEnumServiceStatusA;
  439.   PEnumServiceStatus = PEnumServiceStatusA;
  440. {$ENDIF}
  441.   LPENUM_SERVICE_STATUS_PROCESSA = ^ENUM_SERVICE_STATUS_PROCESSA;
  442.   {$EXTERNALSYM LPENUM_SERVICE_STATUS_PROCESSA}
  443.   _ENUM_SERVICE_STATUS_PROCESSA = record
  444.     lpServiceName: LPSTR;
  445.     lpDisplayName: LPSTR;
  446.     ServiceStatusProcess: SERVICE_STATUS_PROCESS;
  447.   end;
  448.   {$EXTERNALSYM _ENUM_SERVICE_STATUS_PROCESSA}
  449.   ENUM_SERVICE_STATUS_PROCESSA = _ENUM_SERVICE_STATUS_PROCESSA;
  450.   {$EXTERNALSYM ENUM_SERVICE_STATUS_PROCESSA}
  451.   TEnumServiceStatusProcessA = ENUM_SERVICE_STATUS_PROCESSA;
  452.   PEnumServiceStatusProcessA = LPENUM_SERVICE_STATUS_PROCESSA;
  453.   LPENUM_SERVICE_STATUS_PROCESSW = ^ENUM_SERVICE_STATUS_PROCESSW;
  454.   {$EXTERNALSYM LPENUM_SERVICE_STATUS_PROCESSW}
  455.   _ENUM_SERVICE_STATUS_PROCESSW = record
  456.     lpServiceName: LPWSTR;
  457.     lpDisplayName: LPWSTR;
  458.     ServiceStatusProcess: SERVICE_STATUS_PROCESS;
  459.   end;
  460.   {$EXTERNALSYM _ENUM_SERVICE_STATUS_PROCESSW}
  461.   ENUM_SERVICE_STATUS_PROCESSW = _ENUM_SERVICE_STATUS_PROCESSW;
  462.   {$EXTERNALSYM ENUM_SERVICE_STATUS_PROCESSW}
  463.   TEnumServiceStatusProcessW = ENUM_SERVICE_STATUS_PROCESSW;
  464.   PEnumServiceStatusProcessW = LPENUM_SERVICE_STATUS_PROCESSW;
  465. {$IFDEF UNICODE}
  466.   ENUM_SERVICE_STATUS_PROCESS = ENUM_SERVICE_STATUS_PROCESSW;
  467.   {$EXTERNALSYM ENUM_SERVICE_STATUS_PROCESS}
  468.   LPENUM_SERVICE_STATUS_PROCESS = LPENUM_SERVICE_STATUS_PROCESSW;
  469.   {$EXTERNALSYM LPENUM_SERVICE_STATUS_PROCESS}
  470.   TEnumServiceStatusProcess = TEnumServiceStatusProcessW;
  471.   PEnumServiceStatusProcess = PEnumServiceStatusProcessW;
  472. {$ELSE}
  473.   ENUM_SERVICE_STATUS_PROCESS = ENUM_SERVICE_STATUS_PROCESSA;
  474.   {$EXTERNALSYM ENUM_SERVICE_STATUS_PROCESS}
  475.   LPENUM_SERVICE_STATUS_PROCESS = LPENUM_SERVICE_STATUS_PROCESSA;
  476.   {$EXTERNALSYM LPENUM_SERVICE_STATUS_PROCESS}
  477.   TEnumServiceStatusProcess = TEnumServiceStatusProcessA;
  478.   PEnumServiceStatusProcess = PEnumServiceStatusProcessA;
  479. {$ENDIF}
  480. //
  481. // Structures for the Lock API functions
  482. //
  483.   SC_LOCK = LPVOID;
  484.   {$EXTERNALSYM SC_LOCK}
  485.   LPQUERY_SERVICE_LOCK_STATUSA = ^QUERY_SERVICE_LOCK_STATUSA;
  486.   {$EXTERNALSYM LPQUERY_SERVICE_LOCK_STATUSA}
  487.   _QUERY_SERVICE_LOCK_STATUSA = record
  488.     fIsLocked: DWORD;
  489.     lpLockOwner: LPSTR;
  490.     dwLockDuration: DWORD;
  491.   end;
  492.   {$EXTERNALSYM _QUERY_SERVICE_LOCK_STATUSA}
  493.   QUERY_SERVICE_LOCK_STATUSA = _QUERY_SERVICE_LOCK_STATUSA;
  494.   {$EXTERNALSYM QUERY_SERVICE_LOCK_STATUSA}
  495.   TQueryServiceLockStatusA = QUERY_SERVICE_LOCK_STATUSA;
  496.   PQueryServiceLockStatusA = LPQUERY_SERVICE_LOCK_STATUSA;
  497.   LPQUERY_SERVICE_LOCK_STATUSW = ^QUERY_SERVICE_LOCK_STATUSW;
  498.   {$EXTERNALSYM LPQUERY_SERVICE_LOCK_STATUSW}
  499.   _QUERY_SERVICE_LOCK_STATUSW = record
  500.     fIsLocked: DWORD;
  501.     lpLockOwner: LPWSTR;
  502.     dwLockDuration: DWORD;
  503.   end;
  504.   {$EXTERNALSYM _QUERY_SERVICE_LOCK_STATUSW}
  505.   QUERY_SERVICE_LOCK_STATUSW = _QUERY_SERVICE_LOCK_STATUSW;
  506.   {$EXTERNALSYM QUERY_SERVICE_LOCK_STATUSW}
  507.   TQueryServiceLockStatusW = QUERY_SERVICE_LOCK_STATUSW;
  508.   PQueryServiceLockStatusW = LPQUERY_SERVICE_LOCK_STATUSW;
  509. {$IFDEF UNICODE}
  510.   QUERY_SERVICE_LOCK_STATUS = QUERY_SERVICE_LOCK_STATUSW;
  511.   {$EXTERNALSYM QUERY_SERVICE_LOCK_STATUS}
  512.   LPQUERY_SERVICE_LOCK_STATUS = LPQUERY_SERVICE_LOCK_STATUSW;
  513.   {$EXTERNALSYM LPQUERY_SERVICE_LOCK_STATUS}
  514.   TQueryServiceLockStatus = TQueryServiceLockStatusW;
  515.   PQueryServiceLockStatus = PQueryServiceLockStatusW;
  516. {$ELSE}
  517.   QUERY_SERVICE_LOCK_STATUS = QUERY_SERVICE_LOCK_STATUSA;
  518.   {$EXTERNALSYM QUERY_SERVICE_LOCK_STATUS}
  519.   LPQUERY_SERVICE_LOCK_STATUS = LPQUERY_SERVICE_LOCK_STATUSA;
  520.   {$EXTERNALSYM LPQUERY_SERVICE_LOCK_STATUS}
  521.   TQueryServiceLockStatus = TQueryServiceLockStatusA;
  522.   PQueryServiceLockStatus = PQueryServiceLockStatusA;
  523. {$ENDIF}
  524. //
  525. // Query Service Configuration Structure
  526. //
  527.   LPQUERY_SERVICE_CONFIGA = ^QUERY_SERVICE_CONFIGA;
  528.   {$EXTERNALSYM LPQUERY_SERVICE_CONFIGA}
  529.   _QUERY_SERVICE_CONFIGA = record
  530.     dwServiceType: DWORD;
  531.     dwStartType: DWORD;
  532.     dwErrorControl: DWORD;
  533.     lpBinaryPathName: LPSTR;
  534.     lpLoadOrderGroup: LPSTR;
  535.     dwTagId: DWORD;
  536.     lpDependencies: LPSTR;
  537.     lpServiceStartName: LPSTR;
  538.     lpDisplayName: LPSTR;
  539.   end;
  540.   {$EXTERNALSYM _QUERY_SERVICE_CONFIGA}
  541.   QUERY_SERVICE_CONFIGA = _QUERY_SERVICE_CONFIGA;
  542.   {$EXTERNALSYM QUERY_SERVICE_CONFIGA}
  543.   TQueryServiceConfigA = QUERY_SERVICE_CONFIGA;
  544.   PQueryServiceConfigA = LPQUERY_SERVICE_CONFIGA;
  545.   LPQUERY_SERVICE_CONFIGW = ^QUERY_SERVICE_CONFIGW;
  546.   {$EXTERNALSYM LPQUERY_SERVICE_CONFIGW}
  547.   _QUERY_SERVICE_CONFIGW = record
  548.     dwServiceType: DWORD;
  549.     dwStartType: DWORD;
  550.     dwErrorControl: DWORD;
  551.     lpBinaryPathName: LPWSTR;
  552.     lpLoadOrderGroup: LPWSTR;
  553.     dwTagId: DWORD;
  554.     lpDependencies: LPWSTR;
  555.     lpServiceStartName: LPWSTR;
  556.     lpDisplayName: LPWSTR;
  557.   end;
  558.   {$EXTERNALSYM _QUERY_SERVICE_CONFIGW}
  559.   QUERY_SERVICE_CONFIGW = _QUERY_SERVICE_CONFIGW;
  560.   {$EXTERNALSYM QUERY_SERVICE_CONFIGW}
  561.   TQueryServiceConfigW = QUERY_SERVICE_CONFIGW;
  562.   PQueryServiceConfigW = LPQUERY_SERVICE_CONFIGW;
  563. {$IFDEF UNICODE}
  564.   QUERY_SERVICE_CONFIG = QUERY_SERVICE_CONFIGW;
  565.   {$EXTERNALSYM QUERY_SERVICE_CONFIG}
  566.   LPQUERY_SERVICE_CONFIG = LPQUERY_SERVICE_CONFIGW;
  567.   {$EXTERNALSYM LPQUERY_SERVICE_CONFIG}
  568.   TQueryServiceConfig = TQueryServiceConfigW;
  569.   PQueryServiceConfig = PQueryServiceConfigW;
  570. {$ELSE}
  571.   QUERY_SERVICE_CONFIG = QUERY_SERVICE_CONFIGA;
  572.   {$EXTERNALSYM QUERY_SERVICE_CONFIG}
  573.   LPQUERY_SERVICE_CONFIG = LPQUERY_SERVICE_CONFIGA;
  574.   {$EXTERNALSYM LPQUERY_SERVICE_CONFIG}
  575.   TQueryServiceConfig = TQueryServiceConfigA;
  576.   PQueryServiceConfig = PQueryServiceConfigA;
  577. {$ENDIF}
  578. //
  579. // Function Prototype for the Service Main Function
  580. //
  581. type
  582.   LPSERVICE_MAIN_FUNCTIONW = procedure (dwNumServicesArgs: DWORD;
  583.     lpServiceArgVectors: LPWSTR); stdcall;
  584.   {$EXTERNALSYM LPSERVICE_MAIN_FUNCTIONW}
  585.   LPSERVICE_MAIN_FUNCTIONA = procedure (dwNumServicesArgs: DWORD;
  586.     lpServiceArgVectors: LPSTR); stdcall;
  587.   {$EXTERNALSYM LPSERVICE_MAIN_FUNCTIONA}
  588.   TServiceMainFunctionA = LPSERVICE_MAIN_FUNCTIONA;
  589.   TServiceMainFunctionW = LPSERVICE_MAIN_FUNCTIONW;
  590. {$IFDEF UNICODE}
  591.   LPSERVICE_MAIN_FUNCTION = LPSERVICE_MAIN_FUNCTIONW;
  592.   {$EXTERNALSYM LPSERVICE_MAIN_FUNCTION}
  593.   TServiceMainFunction = LPSERVICE_MAIN_FUNCTIONW;
  594. {$ELSE}
  595.   LPSERVICE_MAIN_FUNCTION = LPSERVICE_MAIN_FUNCTIONA;
  596.   {$EXTERNALSYM LPSERVICE_MAIN_FUNCTION}
  597.   TServiceMainFunction = LPSERVICE_MAIN_FUNCTIONA;  
  598. {$ENDIF}
  599. //
  600. // Service Start Table
  601. //
  602.   LPSERVICE_TABLE_ENTRYA = ^SERVICE_TABLE_ENTRYA;
  603.   {$EXTERNALSYM LPSERVICE_TABLE_ENTRYA}
  604.   _SERVICE_TABLE_ENTRYA = record
  605.     lpServiceName: LPSTR;
  606.     lpServiceProc: LPSERVICE_MAIN_FUNCTIONA;
  607.   end;
  608.   {$EXTERNALSYM _SERVICE_TABLE_ENTRYA}
  609.   SERVICE_TABLE_ENTRYA = _SERVICE_TABLE_ENTRYA;
  610.   {$EXTERNALSYM SERVICE_TABLE_ENTRYA}
  611.   TServiceTableEntryA = SERVICE_TABLE_ENTRYA;
  612.   PServiceTableEntryA = LPSERVICE_TABLE_ENTRYA;
  613.   LPSERVICE_TABLE_ENTRYW = ^SERVICE_TABLE_ENTRYW;
  614.   {$EXTERNALSYM LPSERVICE_TABLE_ENTRYW}
  615.   _SERVICE_TABLE_ENTRYW = record
  616.     lpServiceName: LPWSTR;
  617.     lpServiceProc: LPSERVICE_MAIN_FUNCTIONW;
  618.   end;
  619.   {$EXTERNALSYM _SERVICE_TABLE_ENTRYW}
  620.   SERVICE_TABLE_ENTRYW = _SERVICE_TABLE_ENTRYW;
  621.   {$EXTERNALSYM SERVICE_TABLE_ENTRYW}
  622.   TServiceTableEntryW = SERVICE_TABLE_ENTRYW;
  623.   PServiceTableEntryW = LPSERVICE_TABLE_ENTRYW;
  624. {$IFDEF UNICODE}
  625.   SERVICE_TABLE_ENTRY = SERVICE_TABLE_ENTRYW;
  626.   LPSERVICE_TABLE_ENTRY = LPSERVICE_TABLE_ENTRYW;
  627.   TServiceTableEntry = TServiceTableEntryW;
  628.   PServiceTableEntry = PServiceTableEntryW;
  629. {$ELSE}
  630.   SERVICE_TABLE_ENTRY = SERVICE_TABLE_ENTRYA;
  631.   LPSERVICE_TABLE_ENTRY = LPSERVICE_TABLE_ENTRYA;
  632.   TServiceTableEntry = TServiceTableEntryA;
  633.   PServiceTableEntry = PServiceTableEntryA;
  634. {$ENDIF}
  635. //
  636. // Prototype for the Service Control Handler Function
  637. //
  638.   LPHANDLER_FUNCTION = procedure (dwControl: DWORD); stdcall;
  639.   {$EXTERNALSYM LPHANDLER_FUNCTION}
  640.   THandlerFunction = LPHANDLER_FUNCTION;
  641.   LPHANDLER_FUNCTION_EX = function (dwControl, dwEventType: DWORD;
  642.     lpEventData, lpContext: LPVOID): DWORD; stdcall;
  643.   {$EXTERNALSYM LPHANDLER_FUNCTION_EX}
  644.   THandlerFunctionEx = LPHANDLER_FUNCTION_EX;
  645. ///////////////////////////////////////////////////////////////////////////
  646. // API Function Prototypes
  647. ///////////////////////////////////////////////////////////////////////////
  648. function ChangeServiceConfigA(hService: SC_HANDLE; dwServiceType, dwStartType,
  649.   dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: LPCSTR;
  650.   lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  651.   lpDisplayName: LPCSTR): BOOL; stdcall;
  652. {$EXTERNALSYM ChangeServiceConfigA}
  653. function ChangeServiceConfigW(hService: SC_HANDLE; dwServiceType, dwStartType,
  654.   dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: LPCWSTR;
  655.   lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  656.   lpDisplayName: LPCWSTR): BOOL; stdcall;
  657. {$EXTERNALSYM ChangeServiceConfigW}
  658. {$IFDEF UNICODE}
  659. function ChangeServiceConfig(hService: SC_HANDLE; dwServiceType, dwStartType,
  660.   dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: LPCWSTR;
  661.   lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  662.   lpDisplayName: LPCWSTR): BOOL; stdcall;
  663. {$EXTERNALSYM ChangeServiceConfig}
  664. {$ELSE}
  665. function ChangeServiceConfig(hService: SC_HANDLE; dwServiceType, dwStartType,
  666.   dwErrorControl: DWORD; lpBinaryPathName, lpLoadOrderGroup: LPCSTR;
  667.   lpdwTagId: LPDWORD; lpDependencies, lpServiceStartName, lpPassword,
  668.   lpDisplayName: LPCSTR): BOOL; stdcall;
  669. {$EXTERNALSYM ChangeServiceConfig}
  670. {$ENDIF}
  671. function ChangeServiceConfig2A(hService: SC_HANDLE; dwInfoLevel: DWORD;
  672.   lpInfo: LPVOID): BOOL; stdcall;
  673. {$EXTERNALSYM ChangeServiceConfig2A}
  674. function ChangeServiceConfig2W(hService: SC_HANDLE; dwInfoLevel: DWORD;
  675.   lpInfo: LPVOID): BOOL; stdcall;
  676. {$EXTERNALSYM ChangeServiceConfig2W}
  677. {$IFDEF UNICODE}
  678. function ChangeServiceConfig2(hService: SC_HANDLE; dwInfoLevel: DWORD;
  679.   lpInfo: LPVOID): BOOL; stdcall;
  680. {$EXTERNALSYM ChangeServiceConfig2}
  681. {$ELSE}
  682. function ChangeServiceConfig2(hService: SC_HANDLE; dwInfoLevel: DWORD;
  683.   lpInfo: LPVOID): BOOL; stdcall;
  684. {$EXTERNALSYM ChangeServiceConfig2}
  685. {$ENDIF}
  686. function CloseServiceHandle(hSCObject: SC_HANDLE): BOOL; stdcall;
  687. {$EXTERNALSYM CloseServiceHandle}
  688. function ControlService(hService: SC_HANDLE; dwControl: DWORD;
  689.   var lpServiceStatus: SERVICE_STATUS): BOOL; stdcall;
  690. {$EXTERNALSYM ControlService}
  691. function CreateServiceA(hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: LPCSTR;
  692.   dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  693.   lpBinaryPathName, lpLoadOrderGroup: LPCSTR; lpdwTagId: LPDWORD;
  694.   lpDependencies, lpServiceStartName, lpPassword: LPCSTR): SC_HANDLE; stdcall;
  695. {$EXTERNALSYM CreateServiceA}
  696. function CreateServiceW(hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: LPCWSTR;
  697.   dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  698.   lpBinaryPathName, lpLoadOrderGroup: LPCWSTR; lpdwTagId: LPDWORD;
  699.   lpDependencies, lpServiceStartName, lpPassword: LPCWSTR): SC_HANDLE; stdcall;
  700. {$EXTERNALSYM CreateServiceW}
  701. {$IFDEF UNICODE}
  702. function CreateService(hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: LPCWSTR;
  703.   dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  704.   lpBinaryPathName, lpLoadOrderGroup: LPCWSTR; lpdwTagId: LPDWORD;
  705.   lpDependencies, lpServiceStartName, lpPassword: LPCWSTR): SC_HANDLE; stdcall;
  706. {$EXTERNALSYM CreateService}
  707. {$ELSE}
  708. function CreateService(hSCManager: SC_HANDLE; lpServiceName, lpDisplayName: LPCSTR;
  709.   dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl: DWORD;
  710.   lpBinaryPathName, lpLoadOrderGroup: LPCSTR; lpdwTagId: LPDWORD;
  711.   lpDependencies, lpServiceStartName, lpPassword: LPCSTR): SC_HANDLE; stdcall;
  712. {$EXTERNALSYM CreateService}
  713. {$ENDIF}
  714. function DeleteService(hService: SC_HANDLE): BOOL; stdcall;
  715. {$EXTERNALSYM DeleteService}
  716. function EnumDependentServicesA(hService: SC_HANDLE; dwServiceState: DWORD;
  717.   lpServices: LPENUM_SERVICE_STATUSA; cbBufSize: DWORD; var pcbBytesNeeded,
  718.   lpServicesReturned: DWORD): BOOL; stdcall;
  719. {$EXTERNALSYM EnumDependentServicesA}
  720. function EnumDependentServicesW(hService: SC_HANDLE; dwServiceState: DWORD;
  721.   lpServices: LPENUM_SERVICE_STATUSW; cbBufSize: DWORD; var pcbBytesNeeded,
  722.   lpServicesReturned: DWORD): BOOL; stdcall;
  723. {$EXTERNALSYM EnumDependentServicesW}
  724. {$IFDEF UNICODE}
  725. function EnumDependentServices(hService: SC_HANDLE; dwServiceState: DWORD;
  726.   lpServices: LPENUM_SERVICE_STATUSW; cbBufSize: DWORD; var pcbBytesNeeded,
  727.   lpServicesReturned: DWORD): BOOL; stdcall;
  728. {$EXTERNALSYM EnumDependentServices}
  729. {$ELSE}
  730. function EnumDependentServices(hService: SC_HANDLE; dwServiceState: DWORD;
  731.   lpServices: LPENUM_SERVICE_STATUSA; cbBufSize: DWORD; var pcbBytesNeeded,
  732.   lpServicesReturned: DWORD): BOOL; stdcall;
  733. {$EXTERNALSYM EnumDependentServices}
  734. {$ENDIF}
  735. function EnumServicesStatusA(hSCManager: SC_HANDLE; dwServiceType: DWORD;
  736.   dwServiceState: DWORD; lpServices: LPENUM_SERVICE_STATUSA; cbBufSize: DWORD;
  737.   var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  738. {$EXTERNALSYM EnumServicesStatusA}
  739. function EnumServicesStatusW(hSCManager: SC_HANDLE; dwServiceType: DWORD;
  740.   dwServiceState: DWORD; lpServices: LPENUM_SERVICE_STATUSW; cbBufSize: DWORD;
  741.   var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  742. {$EXTERNALSYM EnumServicesStatusW}
  743. {$IFDEF UNICODE}
  744. function EnumServicesStatus(hSCManager: SC_HANDLE; dwServiceType: DWORD;
  745.   dwServiceState: DWORD; lpServices: LPENUM_SERVICE_STATUSW; cbBufSize: DWORD;
  746.   var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  747. {$EXTERNALSYM EnumServicesStatus}
  748. {$ELSE}
  749. function EnumServicesStatus(hSCManager: SC_HANDLE; dwServiceType: DWORD;
  750.   dwServiceState: DWORD; lpServices: LPENUM_SERVICE_STATUSA; cbBufSize: DWORD;
  751.   var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD): BOOL; stdcall;
  752. {$EXTERNALSYM EnumServicesStatus}
  753. {$ENDIF}
  754. function EnumServicesStatusExA(hSCManager: SC_HANDLE; InfoLevel: SC_ENUM_TYPE;
  755.   dwServiceType: DWORD; dwServiceState: DWORD; lpServices: LPBYTE;
  756.   cbBufSize: DWORD; var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD;
  757.   pszGroupName: LPCSTR): BOOL; stdcall;
  758. {$EXTERNALSYM EnumServicesStatusExA}
  759. function EnumServicesStatusExW(hSCManager: SC_HANDLE; InfoLevel: SC_ENUM_TYPE;
  760.   dwServiceType: DWORD; dwServiceState: DWORD; lpServices: LPBYTE;
  761.   cbBufSize: DWORD; var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD;
  762.   pszGroupName: LPCWSTR): BOOL; stdcall;
  763. {$EXTERNALSYM EnumServicesStatusExW}
  764. {$IFDEF UNICODE}
  765. function EnumServicesStatusEx(hSCManager: SC_HANDLE; InfoLevel: SC_ENUM_TYPE;
  766.   dwServiceType: DWORD; dwServiceState: DWORD; lpServices: LPBYTE;
  767.   cbBufSize: DWORD; var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD;
  768.   pszGroupName: LPCWSTR): BOOL; stdcall;
  769. {$EXTERNALSYM EnumServicesStatusEx}
  770. {$ELSE}
  771. function EnumServicesStatusEx(hSCManager: SC_HANDLE; InfoLevel: SC_ENUM_TYPE;
  772.   dwServiceType: DWORD; dwServiceState: DWORD; lpServices: LPBYTE;
  773.   cbBufSize: DWORD; var pcbBytesNeeded, lpServicesReturned, lpResumeHandle: DWORD;
  774.   pszGroupName: LPCSTR): BOOL; stdcall;
  775. {$EXTERNALSYM EnumServicesStatusEx}
  776. {$ENDIF}
  777. function GetServiceKeyNameA(hSCManager: SC_HANDLE; lpDisplayName: LPCSTR;
  778.   lpServiceName: LPSTR; var lpcchBuffer: DWORD): BOOL; stdcall;
  779. {$EXTERNALSYM GetServiceKeyNameA}
  780. function GetServiceKeyNameW(hSCManager: SC_HANDLE; lpDisplayName: LPCWSTR;
  781.   lpServiceName: LPWSTR; var lpcchBuffer: DWORD): BOOL; stdcall;
  782. {$EXTERNALSYM GetServiceKeyNameW}
  783. {$IFDEF UNICODE}
  784. function GetServiceKeyName(hSCManager: SC_HANDLE; lpDisplayName: LPCWSTR;
  785.   lpServiceName: LPWSTR; var lpcchBuffer: DWORD): BOOL; stdcall;
  786. {$EXTERNALSYM GetServiceKeyName}
  787. {$ELSE}
  788. function GetServiceKeyName(hSCManager: SC_HANDLE; lpDisplayName: LPCSTR;
  789.   lpServiceName: LPSTR; var lpcchBuffer: DWORD): BOOL; stdcall;
  790. {$EXTERNALSYM GetServiceKeyName}
  791. {$ENDIF}
  792. function GetServiceDisplayNameA(hSCManager: SC_HANDLE; lpServiceName: LPCSTR;
  793.   lpDisplayName: LPSTR; var lpcchBuffer: DWORD): BOOL; stdcall;
  794. {$EXTERNALSYM GetServiceDisplayNameA}
  795. function GetServiceDisplayNameW(hSCManager: SC_HANDLE; lpServiceName: LPCWSTR;
  796.   lpDisplayName: LPWSTR; var lpcchBuffer: DWORD): BOOL; stdcall;
  797. {$EXTERNALSYM GetServiceDisplayNameW}
  798. {$IFDEF UNICODE}
  799. function GetServiceDisplayName(hSCManager: SC_HANDLE; lpServiceName: LPCWSTR;
  800.   lpDisplayName: LPWSTR; var lpcchBuffer: DWORD): BOOL; stdcall;
  801. {$EXTERNALSYM GetServiceDisplayName}
  802. {$ELSE}
  803. function GetServiceDisplayName(hSCManager: SC_HANDLE; lpServiceName: LPCSTR;
  804.   lpDisplayName: LPSTR; var lpcchBuffer: DWORD): BOOL; stdcall;
  805. {$EXTERNALSYM GetServiceDisplayName}
  806. {$ENDIF}
  807. function LockServiceDatabase(hSCManager: SC_HANDLE): SC_LOCK; stdcall;
  808. {$EXTERNALSYM LockServiceDatabase}
  809. function NotifyBootConfigStatus(BootAcceptable: BOOL): BOOL; stdcall;
  810. {$EXTERNALSYM NotifyBootConfigStatus}
  811. function OpenSCManagerA(lpMachineName: LPCSTR; lpDatabaseName: LPCSTR;
  812.   dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  813. {$EXTERNALSYM OpenSCManagerA}
  814. function OpenSCManagerW(lpMachineName: LPCWSTR; lpDatabaseName: LPCWSTR;
  815.   dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  816. {$EXTERNALSYM OpenSCManagerW}
  817. {$IFDEF UNICODE}
  818. function OpenSCManager(lpMachineName: LPCWSTR; lpDatabaseName: LPCWSTR;
  819.   dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  820. {$EXTERNALSYM OpenSCManager}
  821. {$ELSE}
  822. function OpenSCManager(lpMachineName: LPCSTR; lpDatabaseName: LPCSTR;
  823.   dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  824. {$EXTERNALSYM OpenSCManager}
  825. {$ENDIF}
  826. function OpenServiceA(hSCManager: SC_HANDLE; lpServiceName: LPCSTR;
  827.   dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  828. {$EXTERNALSYM OpenServiceA}
  829. function OpenServiceW(hSCManager: SC_HANDLE; lpServiceName: LPCWSTR;
  830.   dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  831. {$EXTERNALSYM OpenServiceW}
  832. {$IFDEF UNICODE}
  833. function OpenService(hSCManager: SC_HANDLE; lpServiceName: LPCWSTR;
  834.   dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  835. {$EXTERNALSYM OpenService}
  836. {$ELSE}
  837. function OpenService(hSCManager: SC_HANDLE; lpServiceName: LPCSTR;
  838.   dwDesiredAccess: DWORD): SC_HANDLE; stdcall;
  839. {$EXTERNALSYM OpenService}
  840. {$ENDIF}
  841. function QueryServiceConfigA(hService: SC_HANDLE;
  842.   lpServiceConfig: LPQUERY_SERVICE_CONFIGA; cbBufSize: DWORD;
  843.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  844. {$EXTERNALSYM QueryServiceConfigA}
  845. function QueryServiceConfigW(hService: SC_HANDLE;
  846.   lpServiceConfig: LPQUERY_SERVICE_CONFIGW; cbBufSize: DWORD;
  847.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  848. {$EXTERNALSYM QueryServiceConfigW}
  849. {$IFDEF UNICODE}
  850. function QueryServiceConfig(hService: SC_HANDLE;
  851.   lpServiceConfig: LPQUERY_SERVICE_CONFIGW; cbBufSize: DWORD;
  852.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  853. {$EXTERNALSYM QueryServiceConfig}
  854. {$ELSE}
  855. function QueryServiceConfig(hService: SC_HANDLE;
  856.   lpServiceConfig: LPQUERY_SERVICE_CONFIGA; cbBufSize: DWORD;
  857.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  858. {$EXTERNALSYM QueryServiceConfig}
  859. {$ENDIF}
  860. function QueryServiceConfig2A(hService: SC_HANDLE; dwInfoLevel: DWORD;
  861.   lpBuffer: LPBYTE; cbBufSize: DWORD; var pcbBytesNeeded: DWORD): BOOL; stdcall;
  862. {$EXTERNALSYM QueryServiceConfig2A}
  863. function QueryServiceConfig2W(hService: SC_HANDLE; dwInfoLevel: DWORD;
  864.   lpBuffer: LPBYTE; cbBufSize: DWORD; var pcbBytesNeeded: DWORD): BOOL; stdcall;
  865. {$EXTERNALSYM QueryServiceConfig2W}
  866. {$IFDEF UNICODE}
  867. function QueryServiceConfig2(hService: SC_HANDLE; dwInfoLevel: DWORD;
  868.   lpBuffer: LPBYTE; cbBufSize: DWORD; var pcbBytesNeeded: DWORD): BOOL; stdcall;
  869. {$EXTERNALSYM QueryServiceConfig2}
  870. {$ELSE}
  871. function QueryServiceConfig2(hService: SC_HANDLE; dwInfoLevel: DWORD;
  872.   lpBuffer: LPBYTE; cbBufSize: DWORD; var pcbBytesNeeded: DWORD): BOOL; stdcall;
  873. {$EXTERNALSYM QueryServiceConfig2}
  874. {$ENDIF}
  875. function QueryServiceLockStatusA(hSCManager: SC_HANDLE;
  876.   lpLockStatus: LPQUERY_SERVICE_LOCK_STATUSA; cbBufSize: DWORD;
  877.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  878. {$EXTERNALSYM QueryServiceLockStatusA}
  879. function QueryServiceLockStatusW(hSCManager: SC_HANDLE;
  880.   lpLockStatus: LPQUERY_SERVICE_LOCK_STATUSW; cbBufSize: DWORD;
  881.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  882. {$EXTERNALSYM QueryServiceLockStatusW}
  883. {$IFDEF UNICODE}
  884. function QueryServiceLockStatus(hSCManager: SC_HANDLE;
  885.   lpLockStatus: LPQUERY_SERVICE_LOCK_STATUSW; cbBufSize: DWORD;
  886.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  887. {$EXTERNALSYM QueryServiceLockStatus}
  888. {$ELSE}
  889. function QueryServiceLockStatus(hSCManager: SC_HANDLE;
  890.   lpLockStatus: LPQUERY_SERVICE_LOCK_STATUSA; cbBufSize: DWORD;
  891.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  892. {$EXTERNALSYM QueryServiceLockStatus}
  893. {$ENDIF}
  894. function QueryServiceObjectSecurity(hService: SC_HANDLE;
  895.   dwSecurityInformation: SECURITY_INFORMATION;
  896.   var lpSecurityDescriptor: SECURITY_DESCRIPTOR; cbBufSize: DWORD;
  897.   var pcbBytesNeeded: DWORD): BOOL; stdcall;
  898. {$EXTERNALSYM QueryServiceObjectSecurity}
  899. function QueryServiceStatus(hService: SC_HANDLE;
  900.   var lpServiceStatus: SERVICE_STATUS): BOOL; stdcall;
  901. {$EXTERNALSYM QueryServiceStatus}
  902. function QueryServiceStatusEx(hService: SC_HANDLE; InfoLevel: SC_STATUS_TYPE;
  903.   lpBuffer: LPBYTE; cbBufSize: DWORD; var pcbBytesNeeded: DWORD): BOOL; stdcall;
  904. {$EXTERNALSYM QueryServiceStatusEx}
  905. function RegisterServiceCtrlHandlerA(lpServiceName: LPCSTR;
  906.   lpHandlerProc: LPHANDLER_FUNCTION): SERVICE_STATUS_HANDLE; stdcall;
  907. {$EXTERNALSYM RegisterServiceCtrlHandlerA}
  908. function RegisterServiceCtrlHandlerW(lpServiceName: LPCWSTR;
  909.   lpHandlerProc: LPHANDLER_FUNCTION): SERVICE_STATUS_HANDLE; stdcall;
  910. {$EXTERNALSYM RegisterServiceCtrlHandlerW}
  911. {$IFDEF UNICODE}
  912. function RegisterServiceCtrlHandler(lpServiceName: LPCWSTR;
  913.   lpHandlerProc: LPHANDLER_FUNCTION): SERVICE_STATUS_HANDLE; stdcall;
  914. {$EXTERNALSYM RegisterServiceCtrlHandler}
  915. {$ELSE}
  916. function RegisterServiceCtrlHandler(lpServiceName: LPCSTR;
  917.   lpHandlerProc: LPHANDLER_FUNCTION): SERVICE_STATUS_HANDLE; stdcall;
  918. {$EXTERNALSYM RegisterServiceCtrlHandler}
  919. {$ENDIF}
  920. function RegisterServiceCtrlHandlerExA(lpServiceName: LPCSTR;
  921.   lpHandlerProc: LPHANDLER_FUNCTION_EX; lpContext: LPVOID): SERVICE_STATUS_HANDLE; stdcall;
  922. {$EXTERNALSYM RegisterServiceCtrlHandlerExA}
  923. function RegisterServiceCtrlHandlerExW(lpServiceName: LPCWSTR;
  924.   lpHandlerProc: LPHANDLER_FUNCTION_EX; lpContext: LPVOID): SERVICE_STATUS_HANDLE; stdcall;
  925. {$EXTERNALSYM RegisterServiceCtrlHandlerExW}
  926. {$IFDEF UNICODE}
  927. function RegisterServiceCtrlHandlerEx(lpServiceName: LPCWSTR;
  928.   lpHandlerProc: LPHANDLER_FUNCTION_EX; lpContext: LPVOID): SERVICE_STATUS_HANDLE; stdcall;
  929. {$EXTERNALSYM RegisterServiceCtrlHandlerEx}
  930. {$ELSE}
  931. function RegisterServiceCtrlHandlerEx(lpServiceName: LPCSTR;
  932.   lpHandlerProc: LPHANDLER_FUNCTION_EX; lpContext: LPVOID): SERVICE_STATUS_HANDLE; stdcall;
  933. {$EXTERNALSYM RegisterServiceCtrlHandlerEx}
  934. {$ENDIF}
  935. // 9/4/2002 Changed last parameter from const to pointer - reported by James Ots.
  936. function SetServiceObjectSecurity(hService: SC_HANDLE;
  937.   dwSecurityInformation: SECURITY_INFORMATION;
  938.   lpSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  939. {$EXTERNALSYM SetServiceObjectSecurity}
  940. function SetServiceStatus(hServiceStatus: SERVICE_STATUS_HANDLE;
  941.   const lpServiceStatus: SERVICE_STATUS): BOOL; stdcall;
  942. {$EXTERNALSYM SetServiceStatus}
  943. function StartServiceCtrlDispatcherA(lpServiceStartTable: LPSERVICE_TABLE_ENTRYA): BOOL; stdcall;
  944. {$EXTERNALSYM StartServiceCtrlDispatcherA}
  945. function StartServiceCtrlDispatcherW(lpServiceStartTable: LPSERVICE_TABLE_ENTRYW): BOOL; stdcall;
  946. {$EXTERNALSYM StartServiceCtrlDispatcherW}
  947. {$IFDEF UNICODE}
  948. function StartServiceCtrlDispatcher(lpServiceStartTable: LPSERVICE_TABLE_ENTRYW): BOOL; stdcall;
  949. {$EXTERNALSYM StartServiceCtrlDispatcher}
  950. {$ELSE}
  951. function StartServiceCtrlDispatcher(lpServiceStartTable: LPSERVICE_TABLE_ENTRYA): BOOL; stdcall;
  952. {$EXTERNALSYM StartServiceCtrlDispatcher}
  953. {$ENDIF}
  954. function StartServiceA(hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  955.   lpServiceArgVectors: LPCSTR): BOOL; stdcall;
  956. {$EXTERNALSYM StartServiceA}
  957. function StartServiceW(hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  958.   lpServiceArgVectors: LPCWSTR): BOOL; stdcall;
  959. {$EXTERNALSYM StartServiceW}
  960. {$IFDEF UNICODE}
  961. function StartService(hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  962.   lpServiceArgVectors: LPCWSTR): BOOL; stdcall;
  963. {$EXTERNALSYM StartService}
  964. {$ELSE}
  965. function StartService(hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  966.   lpServiceArgVectors: LPCSTR): BOOL; stdcall;
  967. {$EXTERNALSYM StartService}
  968. {$ENDIF}
  969. function UnlockServiceDatabase(ScLock: SC_LOCK): BOOL; stdcall;
  970. {$EXTERNALSYM UnlockServiceDatabase}
  971. implementation
  972. const
  973.   advapi32 = 'advapi32.dll';
  974. {$IFDEF DYNAMIC_LINK}
  975. var
  976.   _ChangeServiceConfigA: Pointer;
  977. function ChangeServiceConfigA;
  978. begin
  979.   GetProcedureAddress(_ChangeServiceConfigA, advapi32, 'ChangeServiceConfigA');
  980.   asm
  981.     mov esp, ebp
  982.     pop ebp
  983.     jmp [_ChangeServiceConfigA]
  984.   end;
  985. end;
  986. {$ELSE}
  987. function ChangeServiceConfigA; external advapi32 name 'ChangeServiceConfigA';
  988. {$ENDIF DYNAMIC_LINK}
  989. {$IFDEF DYNAMIC_LINK}
  990. var
  991.   _ChangeServiceConfigW: Pointer;
  992. function ChangeServiceConfigW;
  993. begin
  994.   GetProcedureAddress(_ChangeServiceConfigW, advapi32, 'ChangeServiceConfigW');
  995.   asm
  996.     mov esp, ebp
  997.     pop ebp
  998.     jmp [_ChangeServiceConfigW]
  999.   end;
  1000. end;
  1001. {$ELSE}
  1002. function ChangeServiceConfigW; external advapi32 name 'ChangeServiceConfigW';
  1003. {$ENDIF DYNAMIC_LINK}
  1004. {$IFDEF UNICODE}
  1005. {$IFDEF DYNAMIC_LINK}
  1006. var
  1007.   _ChangeServiceConfig: Pointer;
  1008. function ChangeServiceConfig;
  1009. begin
  1010.   GetProcedureAddress(_ChangeServiceConfig, advapi32, 'ChangeServiceConfigW');
  1011.   asm
  1012.     mov esp, ebp
  1013.     pop ebp
  1014.     jmp [_ChangeServiceConfig]
  1015.   end;
  1016. end;
  1017. {$ELSE}
  1018. function ChangeServiceConfig; external advapi32 name 'ChangeServiceConfigW';
  1019. {$ENDIF DYNAMIC_LINK}
  1020. {$ELSE}
  1021. {$IFDEF DYNAMIC_LINK}
  1022. var
  1023.   _ChangeServiceConfig: Pointer;
  1024. function ChangeServiceConfig;
  1025. begin
  1026.   GetProcedureAddress(_ChangeServiceConfig, advapi32, 'ChangeServiceConfigA');
  1027.   asm
  1028.     mov esp, ebp
  1029.     pop ebp
  1030.     jmp [_ChangeServiceConfig]
  1031.   end;
  1032. end;
  1033. {$ELSE}
  1034. function ChangeServiceConfig; external advapi32 name 'ChangeServiceConfigA';
  1035. {$ENDIF DYNAMIC_LINK}
  1036. {$ENDIF}
  1037. {$IFDEF DYNAMIC_LINK}
  1038. var
  1039.   _ChangeServiceConfig2A: Pointer;
  1040. function ChangeServiceConfig2A;
  1041. begin
  1042.   GetProcedureAddress(_ChangeServiceConfig2A, advapi32, 'ChangeServiceConfig2A');
  1043.   asm
  1044.     mov esp, ebp
  1045.     pop ebp
  1046.     jmp [_ChangeServiceConfig2A]
  1047.   end;
  1048. end;
  1049. {$ELSE}
  1050. function ChangeServiceConfig2A; external advapi32 name 'ChangeServiceConfig2A';
  1051. {$ENDIF DYNAMIC_LINK}
  1052. {$IFDEF DYNAMIC_LINK}
  1053. var
  1054.   _ChangeServiceConfig2W: Pointer;
  1055. function ChangeServiceConfig2W;
  1056. begin
  1057.   GetProcedureAddress(_ChangeServiceConfig2W, advapi32, 'ChangeServiceConfig2W');
  1058.   asm
  1059.     mov esp, ebp
  1060.     pop ebp
  1061.     jmp [_ChangeServiceConfig2W]
  1062.   end;
  1063. end;
  1064. {$ELSE}
  1065. function ChangeServiceConfig2W; external advapi32 name 'ChangeServiceConfig2W';
  1066. {$ENDIF DYNAMIC_LINK}
  1067. {$IFDEF UNICODE}
  1068. {$IFDEF DYNAMIC_LINK}
  1069. var
  1070.   _ChangeServiceConfig2: Pointer;
  1071. function ChangeServiceConfig2;
  1072. begin
  1073.   GetProcedureAddress(_ChangeServiceConfig2, advapi32, 'ChangeServiceConfig2W');
  1074.   asm
  1075.     mov esp, ebp
  1076.     pop ebp
  1077.     jmp [_ChangeServiceConfig2]
  1078.   end;
  1079. end;
  1080. {$ELSE}
  1081. function ChangeServiceConfig2; external advapi32 name 'ChangeServiceConfig2W';
  1082. {$ENDIF DYNAMIC_LINK}
  1083. {$ELSE}
  1084. {$IFDEF DYNAMIC_LINK}
  1085. var
  1086.   _ChangeServiceConfig2: Pointer;
  1087. function ChangeServiceConfig2;
  1088. begin
  1089.   GetProcedureAddress(_ChangeServiceConfig2, advapi32, 'ChangeServiceConfig2A');
  1090.   asm
  1091.     mov esp, ebp
  1092.     pop ebp
  1093.     jmp [_ChangeServiceConfig2]
  1094.   end;
  1095. end;
  1096. {$ELSE}
  1097. function ChangeServiceConfig2; external advapi32 name 'ChangeServiceConfig2A';
  1098. {$ENDIF DYNAMIC_LINK}
  1099. {$ENDIF}
  1100. {$IFDEF DYNAMIC_LINK}
  1101. var
  1102.   _CloseServiceHandle: Pointer;
  1103. function CloseServiceHandle;
  1104. begin
  1105.   GetProcedureAddress(_CloseServiceHandle, advapi32, 'CloseServiceHandle');
  1106.   asm
  1107.     mov esp, ebp
  1108.     pop ebp
  1109.     jmp [_CloseServiceHandle]
  1110.   end;
  1111. end;
  1112. {$ELSE}
  1113. function CloseServiceHandle; external advapi32 name 'CloseServiceHandle';
  1114. {$ENDIF DYNAMIC_LINK}
  1115. {$IFDEF DYNAMIC_LINK}
  1116. var
  1117.   _ControlService: Pointer;
  1118. function ControlService;
  1119. begin
  1120.   GetProcedureAddress(_ControlService, advapi32, 'ControlService');
  1121.   asm
  1122.     mov esp, ebp
  1123.     pop ebp
  1124.     jmp [_ControlService]
  1125.   end;
  1126. end;
  1127. {$ELSE}
  1128. function ControlService; external advapi32 name 'ControlService';
  1129. {$ENDIF DYNAMIC_LINK}
  1130. {$IFDEF DYNAMIC_LINK}
  1131. var
  1132.   _CreateServiceA: Pointer;
  1133. function CreateServiceA;
  1134. begin
  1135.   GetProcedureAddress(_CreateServiceA, advapi32, 'CreateServiceA');
  1136.   asm
  1137.     mov esp, ebp
  1138.     pop ebp
  1139.     jmp [_CreateServiceA]
  1140.   end;
  1141. end;
  1142. {$ELSE}
  1143. function CreateServiceA; external advapi32 name 'CreateServiceA';
  1144. {$ENDIF DYNAMIC_LINK}
  1145. {$IFDEF DYNAMIC_LINK}
  1146. var
  1147.   _CreateServiceW: Pointer;
  1148. function CreateServiceW;
  1149. begin
  1150.   GetProcedureAddress(_CreateServiceW, advapi32, 'CreateServiceW');
  1151.   asm
  1152.     mov esp, ebp
  1153.     pop ebp
  1154.     jmp [_CreateServiceW]
  1155.   end;
  1156. end;
  1157. {$ELSE}
  1158. function CreateServiceW; external advapi32 name 'CreateServiceW';
  1159. {$ENDIF DYNAMIC_LINK}
  1160. {$IFDEF UNICODE}
  1161. {$IFDEF DYNAMIC_LINK}
  1162. var
  1163.   _CreateService: Pointer;
  1164. function CreateService;
  1165. begin
  1166.   GetProcedureAddress(_CreateService, advapi32, 'CreateServiceW');
  1167.   asm
  1168.     mov esp, ebp
  1169.     pop ebp
  1170.     jmp [_CreateService]
  1171.   end;
  1172. end;
  1173. {$ELSE}
  1174. function CreateService; external advapi32 name 'CreateServiceW';
  1175. {$ENDIF DYNAMIC_LINK}
  1176. {$ELSE}
  1177. {$IFDEF DYNAMIC_LINK}
  1178. var
  1179.   _CreateService: Pointer;
  1180. function CreateService;
  1181. begin
  1182.   GetProcedureAddress(_CreateService, advapi32, 'CreateServiceA');
  1183.   asm
  1184.     mov esp, ebp
  1185.     pop ebp
  1186.     jmp [_CreateService]
  1187.   end;
  1188. end;
  1189. {$ELSE}
  1190. function CreateService; external advapi32 name 'CreateServiceA';
  1191. {$ENDIF DYNAMIC_LINK}
  1192. {$ENDIF}
  1193. {$IFDEF DYNAMIC_LINK}
  1194. var
  1195.   _DeleteService: Pointer;
  1196. function DeleteService;
  1197. begin
  1198.   GetProcedureAddress(_DeleteService, advapi32, 'DeleteService');
  1199.   asm
  1200.     mov esp, ebp
  1201.     pop ebp
  1202.     jmp [_DeleteService]
  1203.   end;
  1204. end;
  1205. {$ELSE}
  1206. function DeleteService; external advapi32 name 'DeleteService';
  1207. {$ENDIF DYNAMIC_LINK}
  1208. {$IFDEF DYNAMIC_LINK}
  1209. var
  1210.   _EnumDependentServicesA: Pointer;
  1211. function EnumDependentServicesA;
  1212. begin
  1213.   GetProcedureAddress(_EnumDependentServicesA, advapi32, 'EnumDependentServicesA');
  1214.   asm
  1215.     mov esp, ebp
  1216.     pop ebp
  1217.     jmp [_EnumDependentServicesA]
  1218.   end;
  1219. end;
  1220. {$ELSE}
  1221. function EnumDependentServicesA; external advapi32 name 'EnumDependentServicesA';
  1222. {$ENDIF DYNAMIC_LINK}
  1223. {$IFDEF DYNAMIC_LINK}
  1224. var
  1225.   _EnumDependentServicesW: Pointer;
  1226. function EnumDependentServicesW;
  1227. begin
  1228.   GetProcedureAddress(_EnumDependentServicesW, advapi32, 'EnumDependentServicesW');
  1229.   asm
  1230.     mov esp, ebp
  1231.     pop ebp
  1232.     jmp [_EnumDependentServicesW]
  1233.   end;
  1234. end;
  1235. {$ELSE}
  1236. function EnumDependentServicesW; external advapi32 name 'EnumDependentServicesW';
  1237. {$ENDIF DYNAMIC_LINK}
  1238. {$IFDEF UNICODE}
  1239. {$IFDEF DYNAMIC_LINK}
  1240. var
  1241.   _EnumDependentServices: Pointer;
  1242. function EnumDependentServices;
  1243. begin
  1244.   GetProcedureAddress(_EnumDependentServices, advapi32, 'EnumDependentServicesW');
  1245.   asm
  1246.     mov esp, ebp
  1247.     pop ebp
  1248.     jmp [_EnumDependentServices]
  1249.   end;
  1250. end;
  1251. {$ELSE}
  1252. function EnumDependentServices; external advapi32 name 'EnumDependentServicesW';
  1253. {$ENDIF DYNAMIC_LINK}
  1254. {$ELSE}
  1255. {$IFDEF DYNAMIC_LINK}
  1256. var
  1257.   _EnumDependentServices: Pointer;
  1258. function EnumDependentServices;
  1259. begin
  1260.   GetProcedureAddress(_EnumDependentServices, advapi32, 'EnumDependentServicesA');
  1261.   asm
  1262.     mov esp, ebp
  1263.     pop ebp
  1264.     jmp [_EnumDependentServices]
  1265.   end;
  1266. end;
  1267. {$ELSE}
  1268. function EnumDependentServices; external advapi32 name 'EnumDependentServicesA';
  1269. {$ENDIF DYNAMIC_LINK}
  1270. {$ENDIF}
  1271. {$IFDEF DYNAMIC_LINK}
  1272. var
  1273.   _EnumServicesStatusA: Pointer;
  1274. function EnumServicesStatusA;
  1275. begin
  1276.   GetProcedureAddress(_EnumServicesStatusA, advapi32, 'EnumServicesStatusA');
  1277.   asm
  1278.     mov esp, ebp
  1279.     pop ebp
  1280.     jmp [_EnumServicesStatusA]
  1281.   end;
  1282. end;
  1283. {$ELSE}
  1284. function EnumServicesStatusA; external advapi32 name 'EnumServicesStatusA';
  1285. {$ENDIF DYNAMIC_LINK}
  1286. {$IFDEF DYNAMIC_LINK}
  1287. var
  1288.   _EnumServicesStatusW: Pointer;
  1289. function EnumServicesStatusW;
  1290. begin
  1291.   GetProcedureAddress(_EnumServicesStatusW, advapi32, 'EnumServicesStatusW');
  1292.   asm
  1293.     mov esp, ebp
  1294.     pop ebp
  1295.     jmp [_EnumServicesStatusW]
  1296.   end;
  1297. end;
  1298. {$ELSE}
  1299. function EnumServicesStatusW; external advapi32 name 'EnumServicesStatusW';
  1300. {$ENDIF DYNAMIC_LINK}
  1301. {$IFDEF UNICODE}
  1302. {$IFDEF DYNAMIC_LINK}
  1303. var
  1304.   _EnumServicesStatus: Pointer;
  1305. function EnumServicesStatus;
  1306. begin
  1307.   GetProcedureAddress(_EnumServicesStatus, advapi32, 'EnumServicesStatusW');
  1308.   asm
  1309.     mov esp, ebp
  1310.     pop ebp
  1311.     jmp [_EnumServicesStatus]
  1312.   end;
  1313. end;
  1314. {$ELSE}
  1315. function EnumServicesStatus; external advapi32 name 'EnumServicesStatusW';
  1316. {$ENDIF DYNAMIC_LINK}
  1317. {$ELSE}
  1318. {$IFDEF DYNAMIC_LINK}
  1319. var
  1320.   _EnumServicesStatus: Pointer;
  1321. function EnumServicesStatus;
  1322. begin
  1323.   GetProcedureAddress(_EnumServicesStatus, advapi32, 'EnumServicesStatusA');
  1324.   asm
  1325.     mov esp, ebp
  1326.     pop ebp
  1327.     jmp [_EnumServicesStatus]
  1328.   end;
  1329. end;
  1330. {$ELSE}
  1331. function EnumServicesStatus; external advapi32 name 'EnumServicesStatusA';
  1332. {$ENDIF DYNAMIC_LINK}
  1333. {$ENDIF}
  1334. {$IFDEF DYNAMIC_LINK}
  1335. var
  1336.   _EnumServicesStatusExA: Pointer;
  1337. function EnumServicesStatusExA;
  1338. begin
  1339.   GetProcedureAddress(_EnumServicesStatusExA, advapi32, 'EnumServicesStatusExA');
  1340.   asm
  1341.     mov esp, ebp
  1342.     pop ebp
  1343.     jmp [_EnumServicesStatusExA]
  1344.   end;
  1345. end;
  1346. {$ELSE}
  1347. function EnumServicesStatusExA; external advapi32 name 'EnumServicesStatusExA';
  1348. {$ENDIF DYNAMIC_LINK}
  1349. {$IFDEF DYNAMIC_LINK}
  1350. var
  1351.   _EnumServicesStatusExW: Pointer;
  1352. function EnumServicesStatusExW;
  1353. begin
  1354.   GetProcedureAddress(_EnumServicesStatusExW, advapi32, 'EnumServicesStatusExW');
  1355.   asm
  1356.     mov esp, ebp
  1357.     pop ebp
  1358.     jmp [_EnumServicesStatusExW]
  1359.   end;
  1360. end;
  1361. {$ELSE}
  1362. function EnumServicesStatusExW; external advapi32 name 'EnumServicesStatusExW';
  1363. {$ENDIF DYNAMIC_LINK}
  1364. {$IFDEF UNICODE}
  1365. {$IFDEF DYNAMIC_LINK}
  1366. var
  1367.   _EnumServicesStatusEx: Pointer;
  1368. function EnumServicesStatusEx;
  1369. begin
  1370.   GetProcedureAddress(_EnumServicesStatusEx, advapi32, 'EnumServicesStatusExW');
  1371.   asm
  1372.     mov esp, ebp
  1373.     pop ebp
  1374.     jmp [_EnumServicesStatusEx]
  1375.   end;
  1376. end;
  1377. {$ELSE}
  1378. function EnumServicesStatusEx; external advapi32 name 'EnumServicesStatusExW';
  1379. {$ENDIF DYNAMIC_LINK}
  1380. {$ELSE}
  1381. {$IFDEF DYNAMIC_LINK}
  1382. var
  1383.   _EnumServicesStatusEx: Pointer;
  1384. function EnumServicesStatusEx;
  1385. begin
  1386.   GetProcedureAddress(_EnumServicesStatusEx, advapi32, 'EnumServicesStatusExA');
  1387.   asm
  1388.     mov esp, ebp
  1389.     pop ebp
  1390.     jmp [_EnumServicesStatusEx]
  1391.   end;
  1392. end;
  1393. {$ELSE}
  1394. function EnumServicesStatusEx; external advapi32 name 'EnumServicesStatusExA';
  1395. {$ENDIF DYNAMIC_LINK}
  1396. {$ENDIF}
  1397. {$IFDEF DYNAMIC_LINK}
  1398. var
  1399.   _GetServiceKeyNameA: Pointer;
  1400. function GetServiceKeyNameA;
  1401. begin
  1402.   GetProcedureAddress(_GetServiceKeyNameA, advapi32, 'GetServiceKeyNameA');
  1403.   asm
  1404.     mov esp, ebp
  1405.     pop ebp
  1406.     jmp [_GetServiceKeyNameA]
  1407.   end;
  1408. end;
  1409. {$ELSE}
  1410. function GetServiceKeyNameA; external advapi32 name 'GetServiceKeyNameA';
  1411. {$ENDIF DYNAMIC_LINK}
  1412. {$IFDEF DYNAMIC_LINK}
  1413. var
  1414.   _GetServiceKeyNameW: Pointer;
  1415. function GetServiceKeyNameW;
  1416. begin
  1417.   GetProcedureAddress(_GetServiceKeyNameW, advapi32, 'GetServiceKeyNameW');
  1418.   asm
  1419.     mov esp, ebp
  1420.     pop ebp
  1421.     jmp [_GetServiceKeyNameW]
  1422.   end;
  1423. end;
  1424. {$ELSE}
  1425. function GetServiceKeyNameW; external advapi32 name 'GetServiceKeyNameW';
  1426. {$ENDIF DYNAMIC_LINK}
  1427. {$IFDEF UNICODE}
  1428. {$IFDEF DYNAMIC_LINK}
  1429. var
  1430.   _GetServiceKeyName: Pointer;
  1431. function GetServiceKeyName;
  1432. begin
  1433.   GetProcedureAddress(_GetServiceKeyName, advapi32, 'GetServiceKeyNameW');
  1434.   asm
  1435.     mov esp, ebp
  1436.     pop ebp
  1437.     jmp [_GetServiceKeyName]
  1438.   end;
  1439. end;
  1440. {$ELSE}
  1441. function GetServiceKeyName; external advapi32 name 'GetServiceKeyNameW';
  1442. {$ENDIF DYNAMIC_LINK}
  1443. {$ELSE}
  1444. {$IFDEF DYNAMIC_LINK}
  1445. var
  1446.   _GetServiceKeyName: Pointer;
  1447. function GetServiceKeyName;
  1448. begin
  1449.   GetProcedureAddress(_GetServiceKeyName, advapi32, 'GetServiceKeyNameA');
  1450.   asm
  1451.     mov esp, ebp
  1452.     pop ebp
  1453.     jmp [_GetServiceKeyName]
  1454.   end;
  1455. end;
  1456. {$ELSE}
  1457. function GetServiceKeyName; external advapi32 name 'GetServiceKeyNameA';
  1458. {$ENDIF DYNAMIC_LINK}
  1459. {$ENDIF}
  1460. {$IFDEF DYNAMIC_LINK}
  1461. var
  1462.   _GetServiceDisplayNameA: Pointer;
  1463. function GetServiceDisplayNameA;
  1464. begin
  1465.   GetProcedureAddress(_GetServiceDisplayNameA, advapi32, 'GetServiceDisplayNameA');
  1466.   asm
  1467.     mov esp, ebp
  1468.     pop ebp
  1469.     jmp [_GetServiceDisplayNameA]
  1470.   end;
  1471. end;
  1472. {$ELSE}
  1473. function GetServiceDisplayNameA; external advapi32 name 'GetServiceDisplayNameA';
  1474. {$ENDIF DYNAMIC_LINK}
  1475. {$IFDEF DYNAMIC_LINK}
  1476. var
  1477.   _GetServiceDisplayNameW: Pointer;
  1478. function GetServiceDisplayNameW;
  1479. begin
  1480.   GetProcedureAddress(_GetServiceDisplayNameW, advapi32, 'GetServiceDisplayNameW');
  1481.   asm
  1482.     mov esp, ebp
  1483.     pop ebp
  1484.     jmp [_GetServiceDisplayNameW]
  1485.   end;
  1486. end;
  1487. {$ELSE}
  1488. function GetServiceDisplayNameW; external advapi32 name 'GetServiceDisplayNameW';
  1489. {$ENDIF DYNAMIC_LINK}
  1490. {$IFDEF UNICODE}
  1491. {$IFDEF DYNAMIC_LINK}
  1492. var
  1493.   _GetServiceDisplayName: Pointer;
  1494. function GetServiceDisplayName;
  1495. begin
  1496.   GetProcedureAddress(_GetServiceDisplayName, advapi32, 'GetServiceDisplayNameW');
  1497.   asm
  1498.     mov esp, ebp
  1499.     pop ebp
  1500.     jmp [_GetServiceDisplayName]
  1501.   end;
  1502. end;
  1503. {$ELSE}
  1504. function GetServiceDisplayName; external advapi32 name 'GetServiceDisplayNameW';
  1505. {$ENDIF DYNAMIC_LINK}
  1506. {$ELSE}
  1507. {$IFDEF DYNAMIC_LINK}
  1508. var
  1509.   _GetServiceDisplayName: Pointer;
  1510. function GetServiceDisplayName;
  1511. begin
  1512.   GetProcedureAddress(_GetServiceDisplayName, advapi32, 'GetServiceDisplayNameA');
  1513.   asm
  1514.     mov esp, ebp
  1515.     pop ebp
  1516.     jmp [_GetServiceDisplayName]
  1517.   end;
  1518. end;
  1519. {$ELSE}
  1520. function GetServiceDisplayName; external advapi32 name 'GetServiceDisplayNameA';
  1521. {$ENDIF DYNAMIC_LINK}
  1522. {$ENDIF}
  1523. {$IFDEF DYNAMIC_LINK}
  1524. var
  1525.   _LockServiceDatabase: Pointer;
  1526. function LockServiceDatabase;
  1527. begin
  1528.   GetProcedureAddress(_LockServiceDatabase, advapi32, 'LockServiceDatabase');
  1529.   asm
  1530.     mov esp, ebp
  1531.     pop ebp
  1532.     jmp [_LockServiceDatabase]
  1533.   end;
  1534. end;
  1535. {$ELSE}
  1536. function LockServiceDatabase; external advapi32 name 'LockServiceDatabase';
  1537. {$ENDIF DYNAMIC_LINK}
  1538. {$IFDEF DYNAMIC_LINK}
  1539. var
  1540.   _NotifyBootConfigStatus: Pointer;
  1541. function NotifyBootConfigStatus;
  1542. begin
  1543.   GetProcedureAddress(_NotifyBootConfigStatus, advapi32, 'NotifyBootConfigStatus');
  1544.   asm
  1545.     mov esp, ebp
  1546.     pop ebp
  1547.     jmp [_NotifyBootConfigStatus]
  1548.   end;
  1549. end;
  1550. {$ELSE}
  1551. function NotifyBootConfigStatus; external advapi32 name 'NotifyBootConfigStatus';
  1552. {$ENDIF DYNAMIC_LINK}
  1553. {$IFDEF DYNAMIC_LINK}
  1554. var
  1555.   _OpenSCManagerA: Pointer;
  1556. function OpenSCManagerA;
  1557. begin
  1558.   GetProcedureAddress(_OpenSCManagerA, advapi32, 'OpenSCManagerA');
  1559.   asm
  1560.     mov esp, ebp
  1561.     pop ebp
  1562.     jmp [_OpenSCManagerA]
  1563.   end;
  1564. end;
  1565. {$ELSE}
  1566. function OpenSCManagerA; external advapi32 name 'OpenSCManagerA';
  1567. {$ENDIF DYNAMIC_LINK}
  1568. {$IFDEF DYNAMIC_LINK}
  1569. var
  1570.   _OpenSCManagerW: Pointer;
  1571. function OpenSCManagerW;
  1572. begin
  1573.   GetProcedureAddress(_OpenSCManagerW, advapi32, 'OpenSCManagerW');
  1574.   asm
  1575.     mov esp, ebp
  1576.     pop ebp
  1577.     jmp [_OpenSCManagerW]
  1578.   end;
  1579. end;
  1580. {$ELSE}
  1581. function OpenSCManagerW; external advapi32 name 'OpenSCManagerW';
  1582. {$ENDIF DYNAMIC_LINK}
  1583. {$IFDEF UNICODE}
  1584. {$IFDEF DYNAMIC_LINK}
  1585. var
  1586.   _OpenSCManager: Pointer;
  1587. function OpenSCManager;
  1588. begin
  1589.   GetProcedureAddress(_OpenSCManager, advapi32, 'OpenSCManagerW');
  1590.   asm
  1591.     mov esp, ebp
  1592.     pop ebp
  1593.     jmp [_OpenSCManager]
  1594.   end;
  1595. end;
  1596. {$ELSE}
  1597. function OpenSCManager; external advapi32 name 'OpenSCManagerW';
  1598. {$ENDIF DYNAMIC_LINK}
  1599. {$ELSE}
  1600. {$IFDEF DYNAMIC_LINK}
  1601. var
  1602.   _OpenSCManager: Pointer;
  1603. function OpenSCManager;
  1604. begin
  1605.   GetProcedureAddress(_OpenSCManager, advapi32, 'OpenSCManagerA');
  1606.   asm
  1607.     mov esp, ebp
  1608.     pop ebp
  1609.     jmp [_OpenSCManager]
  1610.   end;
  1611. end;
  1612. {$ELSE}
  1613. function OpenSCManager; external advapi32 name 'OpenSCManagerA';
  1614. {$ENDIF DYNAMIC_LINK}
  1615. {$ENDIF}
  1616. {$IFDEF DYNAMIC_LINK}
  1617. var
  1618.   _OpenServiceA: Pointer;
  1619. function OpenServiceA;
  1620. begin
  1621.   GetProcedureAddress(_OpenServiceA, advapi32, 'OpenServiceA');
  1622.   asm
  1623.     mov esp, ebp
  1624.     pop ebp
  1625.     jmp [_OpenServiceA]
  1626.   end;
  1627. end;
  1628. {$ELSE}
  1629. function OpenServiceA; external advapi32 name 'OpenServiceA';
  1630. {$ENDIF DYNAMIC_LINK}
  1631. {$IFDEF DYNAMIC_LINK}
  1632. var
  1633.   _OpenServiceW: Pointer;
  1634. function OpenServiceW;
  1635. begin
  1636.   GetProcedureAddress(_OpenServiceW, advapi32, 'OpenServiceW');
  1637.   asm
  1638.     mov esp, ebp
  1639.     pop ebp
  1640.     jmp [_OpenServiceW]
  1641.   end;
  1642. end;
  1643. {$ELSE}
  1644. function OpenServiceW; external advapi32 name 'OpenServiceW';
  1645. {$ENDIF DYNAMIC_LINK}
  1646. {$IFDEF UNICODE}
  1647. {$IFDEF DYNAMIC_LINK}
  1648. var
  1649.   _OpenService: Pointer;
  1650. function OpenService;
  1651. begin
  1652.   GetProcedureAddress(_OpenService, advapi32, 'OpenServiceW');
  1653.   asm
  1654.     mov esp, ebp
  1655.     pop ebp
  1656.     jmp [_OpenService]
  1657.   end;
  1658. end;
  1659. {$ELSE}
  1660. function OpenService; external advapi32 name 'OpenServiceW';
  1661. {$ENDIF DYNAMIC_LINK}
  1662. {$ELSE}
  1663. {$IFDEF DYNAMIC_LINK}
  1664. var
  1665.   _OpenService: Pointer;
  1666. function OpenService;
  1667. begin
  1668.   GetProcedureAddress(_OpenService, advapi32, 'OpenServiceA');
  1669.   asm
  1670.     mov esp, ebp
  1671.     pop ebp
  1672.     jmp [_OpenService]
  1673.   end;
  1674. end;
  1675. {$ELSE}
  1676. function OpenService; external advapi32 name 'OpenServiceA';
  1677. {$ENDIF DYNAMIC_LINK}
  1678. {$ENDIF}
  1679. {$IFDEF DYNAMIC_LINK}
  1680. var
  1681.   _QueryServiceConfigA: Pointer;
  1682. function QueryServiceConfigA;
  1683. begin
  1684.   GetProcedureAddress(_QueryServiceConfigA, advapi32, 'QueryServiceConfigA');
  1685.   asm
  1686.     mov esp, ebp
  1687.     pop ebp
  1688.     jmp [_QueryServiceConfigA]
  1689.   end;
  1690. end;
  1691. {$ELSE}
  1692. function QueryServiceConfigA; external advapi32 name 'QueryServiceConfigA';
  1693. {$ENDIF DYNAMIC_LINK}
  1694. {$IFDEF DYNAMIC_LINK}
  1695. var
  1696.   _QueryServiceConfigW: Pointer;
  1697. function QueryServiceConfigW;
  1698. begin
  1699.   GetProcedureAddress(_QueryServiceConfigW, advapi32, 'QueryServiceConfigW');
  1700.   asm
  1701.     mov esp, ebp
  1702.     pop ebp
  1703.     jmp [_QueryServiceConfigW]
  1704.   end;
  1705. end;
  1706. {$ELSE}
  1707. function QueryServiceConfigW; external advapi32 name 'QueryServiceConfigW';
  1708. {$ENDIF DYNAMIC_LINK}
  1709. {$IFDEF UNICODE}
  1710. {$IFDEF DYNAMIC_LINK}
  1711. var
  1712.   _QueryServiceConfig: Pointer;
  1713. function QueryServiceConfig;
  1714. begin
  1715.   GetProcedureAddress(_QueryServiceConfig, advapi32, 'QueryServiceConfigW');
  1716.   asm
  1717.     mov esp, ebp
  1718.     pop ebp
  1719.     jmp [_QueryServiceConfig]
  1720.   end;
  1721. end;
  1722. {$ELSE}
  1723. function QueryServiceConfig; external advapi32 name 'QueryServiceConfigW';
  1724. {$ENDIF DYNAMIC_LINK}
  1725. {$ELSE}
  1726. {$IFDEF DYNAMIC_LINK}
  1727. var
  1728.   _QueryServiceConfig: Pointer;
  1729. function QueryServiceConfig;
  1730. begin
  1731.   GetProcedureAddress(_QueryServiceConfig, advapi32, 'QueryServiceConfigA');
  1732.   asm
  1733.     mov esp, ebp
  1734.     pop ebp
  1735.     jmp [_QueryServiceConfig]
  1736.   end;
  1737. end;
  1738. {$ELSE}
  1739. function QueryServiceConfig; external advapi32 name 'QueryServiceConfigA';
  1740. {$ENDIF DYNAMIC_LINK}
  1741. {$ENDIF}
  1742. {$IFDEF DYNAMIC_LINK}
  1743. var
  1744.   _QueryServiceConfig2A: Pointer;
  1745. function QueryServiceConfig2A;
  1746. begin
  1747.   GetProcedureAddress(_QueryServiceConfig2A, advapi32, 'QueryServiceConfig2A');
  1748.   asm
  1749.     mov esp, ebp
  1750.     pop ebp
  1751.     jmp [_QueryServiceConfig2A]
  1752.   end;
  1753. end;
  1754. {$ELSE}
  1755. function QueryServiceConfig2A; external advapi32 name 'QueryServiceConfig2A';
  1756. {$ENDIF DYNAMIC_LINK}
  1757. {$IFDEF DYNAMIC_LINK}
  1758. var
  1759.   _QueryServiceConfig2W: Pointer;
  1760. function QueryServiceConfig2W;
  1761. begin
  1762.   GetProcedureAddress(_QueryServiceConfig2W, advapi32, 'QueryServiceConfig2W');
  1763.   asm
  1764.     mov esp, ebp
  1765.     pop ebp
  1766.     jmp [_QueryServiceConfig2W]
  1767.   end;
  1768. end;
  1769. {$ELSE}
  1770. function QueryServiceConfig2W; external advapi32 name 'QueryServiceConfig2W';
  1771. {$ENDIF DYNAMIC_LINK}
  1772. {$IFDEF UNICODE}
  1773. {$IFDEF DYNAMIC_LINK}
  1774. var
  1775.   _QueryServiceConfig2: Pointer;
  1776. function QueryServiceConfig2;
  1777. begin
  1778.   GetProcedureAddress(_QueryServiceConfig2, advapi32, 'QueryServiceConfig2W');
  1779.   asm
  1780.     mov esp, ebp
  1781.     pop ebp
  1782.     jmp [_QueryServiceConfig2]
  1783.   end;
  1784. end;
  1785. {$ELSE}
  1786. function QueryServiceConfig2; external advapi32 name 'QueryServiceConfig2W';
  1787. {$ENDIF DYNAMIC_LINK}
  1788. {$ELSE}
  1789. {$IFDEF DYNAMIC_LINK}
  1790. var
  1791.   _QueryServiceConfig2: Pointer;
  1792. function QueryServiceConfig2;
  1793. begin
  1794.   GetProcedureAddress(_QueryServiceConfig2, advapi32, 'QueryServiceConfig2A');
  1795.   asm
  1796.     mov esp, ebp
  1797.     pop ebp
  1798.     jmp [_QueryServiceConfig2]
  1799.   end;
  1800. end;
  1801. {$ELSE}
  1802. function QueryServiceConfig2; external advapi32 name 'QueryServiceConfig2A';
  1803. {$ENDIF DYNAMIC_LINK}
  1804. {$ENDIF}
  1805. {$IFDEF DYNAMIC_LINK}
  1806. var
  1807.   _QueryServiceLockStatusA: Pointer;
  1808. function QueryServiceLockStatusA;
  1809. begin
  1810.   GetProcedureAddress(_QueryServiceLockStatusA, advapi32, 'QueryServiceLockStatusA');
  1811.   asm
  1812.     mov esp, ebp
  1813.     pop ebp
  1814.     jmp [_QueryServiceLockStatusA]
  1815.   end;
  1816. end;
  1817. {$ELSE}
  1818. function QueryServiceLockStatusA; external advapi32 name 'QueryServiceLockStatusA';
  1819. {$ENDIF DYNAMIC_LINK}
  1820. {$IFDEF DYNAMIC_LINK}
  1821. var
  1822.   _QueryServiceLockStatusW: Pointer;
  1823. function QueryServiceLockStatusW;
  1824. begin
  1825.   GetProcedureAddress(_QueryServiceLockStatusW, advapi32, 'QueryServiceLockStatusW');
  1826.   asm
  1827.     mov esp, ebp
  1828.     pop ebp
  1829.     jmp [_QueryServiceLockStatusW]
  1830.   end;
  1831. end;
  1832. {$ELSE}
  1833. function QueryServiceLockStatusW; external advapi32 name 'QueryServiceLockStatusW';
  1834. {$ENDIF DYNAMIC_LINK}
  1835. {$IFDEF UNICODE}
  1836. {$IFDEF DYNAMIC_LINK}
  1837. var
  1838.   _QueryServiceLockStatus: Pointer;
  1839. function QueryServiceLockStatus;
  1840. begin
  1841.   GetProcedureAddress(_QueryServiceLockStatus, advapi32, 'QueryServiceLockStatusW');
  1842.   asm
  1843.     mov esp, ebp
  1844.     pop ebp
  1845.     jmp [_QueryServiceLockStatus]
  1846.   end;
  1847. end;
  1848. {$ELSE}
  1849. function QueryServiceLockStatus; external advapi32 name 'QueryServiceLockStatusW';
  1850. {$ENDIF DYNAMIC_LINK}
  1851. {$ELSE}
  1852. {$IFDEF DYNAMIC_LINK}
  1853. var
  1854.   _QueryServiceLockStatus: Pointer;
  1855. function QueryServiceLockStatus;
  1856. begin
  1857.   GetProcedureAddress(_QueryServiceLockStatus, advapi32, 'QueryServiceLockStatusA');
  1858.   asm
  1859.     mov esp, ebp
  1860.     pop ebp
  1861.     jmp [_QueryServiceLockStatus]
  1862.   end;
  1863. end;
  1864. {$ELSE}
  1865. function QueryServiceLockStatus; external advapi32 name 'QueryServiceLockStatusA';
  1866. {$ENDIF DYNAMIC_LINK}
  1867. {$ENDIF}
  1868. {$IFDEF DYNAMIC_LINK}
  1869. var
  1870.   _QueryServiceObjectSecurity: Pointer;
  1871. function QueryServiceObjectSecurity;
  1872. begin
  1873.   GetProcedureAddress(_QueryServiceObjectSecurity, advapi32, 'QueryServiceObjectSecurity');
  1874.   asm
  1875.     mov esp, ebp
  1876.     pop ebp
  1877.     jmp [_QueryServiceObjectSecurity]
  1878.   end;
  1879. end;
  1880. {$ELSE}
  1881. function QueryServiceObjectSecurity; external advapi32 name 'QueryServiceObjectSecurity';
  1882. {$ENDIF DYNAMIC_LINK}
  1883. {$IFDEF DYNAMIC_LINK}
  1884. var
  1885.   _QueryServiceStatus: Pointer;
  1886. function QueryServiceStatus;
  1887. begin
  1888.   GetProcedureAddress(_QueryServiceStatus, advapi32, 'QueryServiceStatus');
  1889.   asm
  1890.     mov esp, ebp
  1891.     pop ebp
  1892.     jmp [_QueryServiceStatus]
  1893.   end;
  1894. end;
  1895. {$ELSE}
  1896. function QueryServiceStatus; external advapi32 name 'QueryServiceStatus';
  1897. {$ENDIF DYNAMIC_LINK}
  1898. {$IFDEF DYNAMIC_LINK}
  1899. var
  1900.   _QueryServiceStatusEx: Pointer;
  1901. function QueryServiceStatusEx;
  1902. begin
  1903.   GetProcedureAddress(_QueryServiceStatusEx, advapi32, 'QueryServiceStatusEx');
  1904.   asm
  1905.     mov esp, ebp
  1906.     pop ebp
  1907.     jmp [_QueryServiceStatusEx]
  1908.   end;
  1909. end;
  1910. {$ELSE}
  1911. function QueryServiceStatusEx; external advapi32 name 'QueryServiceStatusEx';
  1912. {$ENDIF DYNAMIC_LINK}
  1913. {$IFDEF DYNAMIC_LINK}
  1914. var
  1915.   _RegisterServiceCtrlHandlerA: Pointer;
  1916. function RegisterServiceCtrlHandlerA;
  1917. begin
  1918.   GetProcedureAddress(_RegisterServiceCtrlHandlerA, advapi32, 'RegisterServiceCtrlHandlerA');
  1919.   asm
  1920.     mov esp, ebp
  1921.     pop ebp
  1922.     jmp [_RegisterServiceCtrlHandlerA]
  1923.   end;
  1924. end;
  1925. {$ELSE}
  1926. function RegisterServiceCtrlHandlerA; external advapi32 name 'RegisterServiceCtrlHandlerA';
  1927. {$ENDIF DYNAMIC_LINK}
  1928. {$IFDEF DYNAMIC_LINK}
  1929. var
  1930.   _RegisterServiceCtrlHandlerW: Pointer;
  1931. function RegisterServiceCtrlHandlerW;
  1932. begin
  1933.   GetProcedureAddress(_RegisterServiceCtrlHandlerW, advapi32, 'RegisterServiceCtrlHandlerW');
  1934.   asm
  1935.     mov esp, ebp
  1936.     pop ebp
  1937.     jmp [_RegisterServiceCtrlHandlerW]
  1938.   end;
  1939. end;
  1940. {$ELSE}
  1941. function RegisterServiceCtrlHandlerW; external advapi32 name 'RegisterServiceCtrlHandlerW';
  1942. {$ENDIF DYNAMIC_LINK}
  1943. {$IFDEF UNICODE}
  1944. {$IFDEF DYNAMIC_LINK}
  1945. var
  1946.   _RegisterServiceCtrlHandler: Pointer;
  1947. function RegisterServiceCtrlHandler;
  1948. begin
  1949.   GetProcedureAddress(_RegisterServiceCtrlHandler, advapi32, 'RegisterServiceCtrlHandlerW');
  1950.   asm
  1951.     mov esp, ebp
  1952.     pop ebp
  1953.     jmp [_RegisterServiceCtrlHandler]
  1954.   end;
  1955. end;
  1956. {$ELSE}
  1957. function RegisterServiceCtrlHandler; external advapi32 name 'RegisterServiceCtrlHandlerW';
  1958. {$ENDIF DYNAMIC_LINK}
  1959. {$ELSE}
  1960. {$IFDEF DYNAMIC_LINK}
  1961. var
  1962.   _RegisterServiceCtrlHandler: Pointer;
  1963. function RegisterServiceCtrlHandler;
  1964. begin
  1965.   GetProcedureAddress(_RegisterServiceCtrlHandler, advapi32, 'RegisterServiceCtrlHandlerA');
  1966.   asm
  1967.     mov esp, ebp
  1968.     pop ebp
  1969.     jmp [_RegisterServiceCtrlHandler]
  1970.   end;
  1971. end;
  1972. {$ELSE}
  1973. function RegisterServiceCtrlHandler; external advapi32 name 'RegisterServiceCtrlHandlerA';
  1974. {$ENDIF DYNAMIC_LINK}
  1975. {$ENDIF}
  1976. {$IFDEF DYNAMIC_LINK}
  1977. var
  1978.   _RegisterServiceCtrlHandlerExA: Pointer;
  1979. function RegisterServiceCtrlHandlerExA;
  1980. begin
  1981.   GetProcedureAddress(_RegisterServiceCtrlHandlerExA, advapi32, 'RegisterServiceCtrlHandlerExA');
  1982.   asm
  1983.     mov esp, ebp
  1984.     pop ebp
  1985.     jmp [_RegisterServiceCtrlHandlerExA]
  1986.   end;
  1987. end;
  1988. {$ELSE}
  1989. function RegisterServiceCtrlHandlerExA; external advapi32 name 'RegisterServiceCtrlHandlerExA';
  1990. {$ENDIF DYNAMIC_LINK}
  1991. {$IFDEF DYNAMIC_LINK}
  1992. var
  1993.   _RegisterServiceCtrlHandlerExW: Pointer;
  1994. function RegisterServiceCtrlHandlerExW;
  1995. begin
  1996.   GetProcedureAddress(_RegisterServiceCtrlHandlerExW, advapi32, 'RegisterServiceCtrlHandlerExW');
  1997.   asm
  1998.     mov esp, ebp
  1999.     pop ebp
  2000.     jmp [_RegisterServiceCtrlHandlerExW]
  2001.   end;
  2002. end;
  2003. {$ELSE}
  2004. function RegisterServiceCtrlHandlerExW; external advapi32 name 'RegisterServiceCtrlHandlerExW';
  2005. {$ENDIF DYNAMIC_LINK}
  2006. {$IFDEF UNICODE}
  2007. {$IFDEF DYNAMIC_LINK}
  2008. var
  2009.   _RegisterServiceCtrlHandlerEx: Pointer;
  2010. function RegisterServiceCtrlHandlerEx;
  2011. begin
  2012.   GetProcedureAddress(_RegisterServiceCtrlHandlerEx, advapi32, 'RegisterServiceCtrlHandlerExW');
  2013.   asm
  2014.     mov esp, ebp
  2015.     pop ebp
  2016.     jmp [_RegisterServiceCtrlHandlerEx]
  2017.   end;
  2018. end;
  2019. {$ELSE}
  2020. function RegisterServiceCtrlHandlerEx; external advapi32 name 'RegisterServiceCtrlHandlerExW';
  2021. {$ENDIF DYNAMIC_LINK}
  2022. {$ELSE}
  2023. {$IFDEF DYNAMIC_LINK}
  2024. var
  2025.   _RegisterServiceCtrlHandlerEx: Pointer;
  2026. function RegisterServiceCtrlHandlerEx;
  2027. begin
  2028.   GetProcedureAddress(_RegisterServiceCtrlHandlerEx, advapi32, 'RegisterServiceCtrlHandlerExA');
  2029.   asm
  2030.     mov esp, ebp
  2031.     pop ebp
  2032.     jmp [_RegisterServiceCtrlHandlerEx]
  2033.   end;
  2034. end;
  2035. {$ELSE}
  2036. function RegisterServiceCtrlHandlerEx; external advapi32 name 'RegisterServiceCtrlHandlerExA';
  2037. {$ENDIF DYNAMIC_LINK}
  2038. {$ENDIF}
  2039. {$IFDEF DYNAMIC_LINK}
  2040. var
  2041.   _SetServiceObjectSecurity: Pointer;
  2042. function SetServiceObjectSecurity;
  2043. begin
  2044.   GetProcedureAddress(_SetServiceObjectSecurity, advapi32, 'SetServiceObjectSecurity');
  2045.   asm
  2046.     mov esp, ebp
  2047.     pop ebp
  2048.     jmp [_SetServiceObjectSecurity]
  2049.   end;
  2050. end;
  2051. {$ELSE}
  2052. function SetServiceObjectSecurity; external advapi32 name 'SetServiceObjectSecurity';
  2053. {$ENDIF DYNAMIC_LINK}
  2054. {$IFDEF DYNAMIC_LINK}
  2055. var
  2056.   _SetServiceStatus: Pointer;
  2057. function SetServiceStatus;
  2058. begin
  2059.   GetProcedureAddress(_SetServiceStatus, advapi32, 'SetServiceStatus');
  2060.   asm
  2061.     mov esp, ebp
  2062.     pop ebp
  2063.     jmp [_SetServiceStatus]
  2064.   end;
  2065. end;
  2066. {$ELSE}
  2067. function SetServiceStatus; external advapi32 name 'SetServiceStatus';
  2068. {$ENDIF DYNAMIC_LINK}
  2069. {$IFDEF DYNAMIC_LINK}
  2070. var
  2071.   _StartServiceCtrlDispatcherA: Pointer;
  2072. function StartServiceCtrlDispatcherA;
  2073. begin
  2074.   GetProcedureAddress(_StartServiceCtrlDispatcherA, advapi32, 'StartServiceCtrlDispatcherA');
  2075.   asm
  2076.     mov esp, ebp
  2077.     pop ebp
  2078.     jmp [_StartServiceCtrlDispatcherA]
  2079.   end;
  2080. end;
  2081. {$ELSE}
  2082. function StartServiceCtrlDispatcherA; external advapi32 name 'StartServiceCtrlDispatcherA';
  2083. {$ENDIF DYNAMIC_LINK}
  2084. {$IFDEF DYNAMIC_LINK}
  2085. var
  2086.   _StartServiceCtrlDispatcherW: Pointer;
  2087. function StartServiceCtrlDispatcherW;
  2088. begin
  2089.   GetProcedureAddress(_StartServiceCtrlDispatcherW, advapi32, 'StartServiceCtrlDispatcherW');
  2090.   asm
  2091.     mov esp, ebp
  2092.     pop ebp
  2093.     jmp [_StartServiceCtrlDispatcherW]
  2094.   end;
  2095. end;
  2096. {$ELSE}
  2097. function StartServiceCtrlDispatcherW; external advapi32 name 'StartServiceCtrlDispatcherW';
  2098. {$ENDIF DYNAMIC_LINK}
  2099. {$IFDEF UNICODE}
  2100. {$IFDEF DYNAMIC_LINK}
  2101. var
  2102.   _StartServiceCtrlDispatcher: Pointer;
  2103. function StartServiceCtrlDispatcher;
  2104. begin
  2105.   GetProcedureAddress(_StartServiceCtrlDispatcher, advapi32, 'StartServiceCtrlDispatcherW');
  2106.   asm
  2107.     mov esp, ebp
  2108.     pop ebp
  2109.     jmp [_StartServiceCtrlDispatcher]
  2110.   end;
  2111. end;
  2112. {$ELSE}
  2113. function StartServiceCtrlDispatcher; external advapi32 name 'StartServiceCtrlDispatcherW';
  2114. {$ENDIF DYNAMIC_LINK}
  2115. {$ELSE}
  2116. {$IFDEF DYNAMIC_LINK}
  2117. var
  2118.   _StartServiceCtrlDispatcher: Pointer;
  2119. function StartServiceCtrlDispatcher;
  2120. begin
  2121.   GetProcedureAddress(_StartServiceCtrlDispatcher, advapi32, 'StartServiceCtrlDispatcherA');
  2122.   asm
  2123.     mov esp, ebp
  2124.     pop ebp
  2125.     jmp [_StartServiceCtrlDispatcher]
  2126.   end;
  2127. end;
  2128. {$ELSE}
  2129. function StartServiceCtrlDispatcher; external advapi32 name 'StartServiceCtrlDispatcherA';
  2130. {$ENDIF DYNAMIC_LINK}
  2131. {$ENDIF}
  2132. {$IFDEF DYNAMIC_LINK}
  2133. var
  2134.   _StartServiceA: Pointer;
  2135. function StartServiceA;
  2136. begin
  2137.   GetProcedureAddress(_StartServiceA, advapi32, 'StartServiceA');
  2138.   asm
  2139.     mov esp, ebp
  2140.     pop ebp
  2141.     jmp [_StartServiceA]
  2142.   end;
  2143. end;
  2144. {$ELSE}
  2145. function StartServiceA; external advapi32 name 'StartServiceA';
  2146. {$ENDIF DYNAMIC_LINK}
  2147. {$IFDEF DYNAMIC_LINK}
  2148. var
  2149.   _StartServiceW: Pointer;
  2150. function StartServiceW;
  2151. begin
  2152.   GetProcedureAddress(_StartServiceW, advapi32, 'StartServiceW');
  2153.   asm
  2154.     mov esp, ebp
  2155.     pop ebp
  2156.     jmp [_StartServiceW]
  2157.   end;
  2158. end;
  2159. {$ELSE}
  2160. function StartServiceW; external advapi32 name 'StartServiceW';
  2161. {$ENDIF DYNAMIC_LINK}
  2162. {$IFDEF UNICODE}
  2163. {$IFDEF DYNAMIC_LINK}
  2164. var
  2165.   _StartService: Pointer;
  2166. function StartService;
  2167. begin
  2168.   GetProcedureAddress(_StartService, advapi32, 'StartServiceW');
  2169.   asm
  2170.     mov esp, ebp
  2171.     pop ebp
  2172.     jmp [_StartService]
  2173.   end;
  2174. end;
  2175. {$ELSE}
  2176. function StartService; external advapi32 name 'StartServiceW';
  2177. {$ENDIF DYNAMIC_LINK}
  2178. {$ELSE}
  2179. {$IFDEF DYNAMIC_LINK}
  2180. var
  2181.   _StartService: Pointer;
  2182. function StartService;
  2183. begin
  2184.   GetProcedureAddress(_StartService, advapi32, 'StartServiceA');
  2185.   asm
  2186.     mov esp, ebp
  2187.     pop ebp
  2188.     jmp [_StartService]
  2189.   end;
  2190. end;
  2191. {$ELSE}
  2192. function StartService; external advapi32 name 'StartServiceA';
  2193. {$ENDIF DYNAMIC_LINK}
  2194. {$ENDIF}
  2195. {$IFDEF DYNAMIC_LINK}
  2196. var
  2197.   _UnlockServiceDatabase: Pointer;
  2198. function UnlockServiceDatabase;
  2199. begin
  2200.   GetProcedureAddress(_UnlockServiceDatabase, advapi32, 'UnlockServiceDatabase');
  2201.   asm
  2202.     mov esp, ebp
  2203.     pop ebp
  2204.     jmp [_UnlockServiceDatabase]
  2205.   end;
  2206. end;
  2207. {$ELSE}
  2208. function UnlockServiceDatabase; external advapi32 name 'UnlockServiceDatabase';
  2209. {$ENDIF DYNAMIC_LINK}
  2210. end.