⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jwalmsvc.pas

📁 比较全面的win32api开发包
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{******************************************************************************}
{                                                       	               }
{ Lan Manager Service API interface Unit for Object Pascal                     }
{                                                       	               }
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
{ Corporation. All Rights Reserved.                                            }
{ 								               }
{ The original file is: lmsvc.h, released November 2001. The original Pascal   }
{ code is: LmSvc.pas, released Februari 2002. The initial developer of the     }
{ Pascal code is Marcel van Brakel (brakelm@chello.nl).                        }
{                                                                              }
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
{ Marcel van Brakel. All Rights Reserved.                                      }
{ 								               }
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
{								               }
{ You may retrieve the latest version of this file at the Project JEDI home    }
{ page, located at http://delphi-jedi.org or my personal homepage located at   }
{ http://members.chello.nl/m.vanbrakel2                                        }
{								               }
{ The contents of this file are used with permission, subject to the Mozilla   }
{ Public License Version 1.1 (the "License"); you may not use this file except }
{ in compliance with the License. You may obtain a copy of the License at      }
{ http://www.mozilla.org/MPL/MPL-1.1.html                                      }
{                                                                              }
{ Software distributed under the License is distributed on an "AS IS" basis,   }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License.    }
{                                                                              }
{ Alternatively, the contents of this file may be used under the terms of the  }
{ GNU Lesser General Public License (the  "LGPL License"), in which case the   }
{ provisions of the LGPL License are applicable instead of those above.        }
{ If you wish to allow use of your version of this file only under the terms   }
{ of the LGPL License and not to allow others to use your version of this file }
{ under the MPL, indicate your decision by deleting  the provisions above and  }
{ replace  them with the notice and other provisions required by the LGPL      }
{ License.  If you do not delete the provisions above, a recipient may use     }
{ your version of this file under either the MPL or the LGPL License.          }
{ 								               }
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
{ 								               }
{******************************************************************************}

unit JwaLmSvc;

{$WEAKPACKAGEUNIT}

{$HPPEMIT ''}
{$HPPEMIT '#include "lmsvc.h"'}
{$HPPEMIT ''}

{$I WINDEFINES.INC}

interface

uses
  JwaLmCons, JwaWinType;

//
//  Data Structures
//

type
  LPSERVICE_INFO_0 = ^SERVICE_INFO_0;
  {$EXTERNALSYM LPSERVICE_INFO_0}
  PSERVICE_INFO_0 = ^SERVICE_INFO_0;
  {$EXTERNALSYM PSERVICE_INFO_0}
  _SERVICE_INFO_0 = record
    svci0_name: LPWSTR;
  end;
  {$EXTERNALSYM _SERVICE_INFO_0}
  SERVICE_INFO_0 = _SERVICE_INFO_0;
  {$EXTERNALSYM SERVICE_INFO_0}
  TServiceInfo0 = SERVICE_INFO_0;
  PServiceInfo0 = PSERVICE_INFO_0;

  LPSERVICE_INFO_1 = ^SERVICE_INFO_1;
  {$EXTERNALSYM LPSERVICE_INFO_1}
  PSERVICE_INFO_1 = ^SERVICE_INFO_1;
  {$EXTERNALSYM PSERVICE_INFO_1}
  _SERVICE_INFO_1 = record
    svci1_name: LPWSTR;
    svci1_status: DWORD;
    svci1_code: DWORD;
    svci1_pid: DWORD;
  end;
  {$EXTERNALSYM _SERVICE_INFO_1}
  SERVICE_INFO_1 = _SERVICE_INFO_1;
  {$EXTERNALSYM SERVICE_INFO_1}
  TServiceInfo1 = SERVICE_INFO_1;
  PServiceInfo1 = PSERVICE_INFO_1;

  LPSERVICE_INFO_2 = ^SERVICE_INFO_2;
  {$EXTERNALSYM LPSERVICE_INFO_2}
  PSERVICE_INFO_2 = ^SERVICE_INFO_2;
  {$EXTERNALSYM PSERVICE_INFO_2}
  _SERVICE_INFO_2 = record
    svci2_name: LPWSTR;
    svci2_status: DWORD;
    svci2_code: DWORD;
    svci2_pid: DWORD;
    svci2_text: LPWSTR;
    svci2_specific_error: DWORD;
    svci2_display_name: LPWSTR;
  end;
  {$EXTERNALSYM _SERVICE_INFO_2}
  SERVICE_INFO_2 = _SERVICE_INFO_2;
  {$EXTERNALSYM SERVICE_INFO_2}
  TServiceInfo2 = SERVICE_INFO_2;
  PServiceInfo2 = PSERVICE_INFO_2;

//
// Function Prototypes
//

function NetServiceControl(servername, service: LPCWSTR; opcode: DWORD; arg: DWORD; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
{$EXTERNALSYM NetServiceControl}

function NetServiceEnum(servername: LPCWSTR; level: DWORD; var bufptr: LPBYTE; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; stdcall;
{$EXTERNALSYM NetServiceEnum}

function NetServiceGetInfo(servername, service: LPCWSTR; level: DWORD; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
{$EXTERNALSYM NetServiceGetInfo}

function NetServiceInstall(servername, service: LPCWSTR; argc: DWORD; argv: LPCWSTR; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
{$EXTERNALSYM NetServiceInstall}

//
// Special Values and Constants
//

//
//  Bitmask and bit values for svci1_status, and svci2_status
//  fields.  For each "subfield", there is a mask defined,
//  and a number of constants representing the value
//  obtained by doing (status & mask).
//

// Bits 0,1 -- general status

const
  SERVICE_INSTALL_STATE     = $03;
  {$EXTERNALSYM SERVICE_INSTALL_STATE}
  SERVICE_UNINSTALLED       = $00;
  {$EXTERNALSYM SERVICE_UNINSTALLED}
  SERVICE_INSTALL_PENDING   = $01;
  {$EXTERNALSYM SERVICE_INSTALL_PENDING}
  SERVICE_UNINSTALL_PENDING = $02;
  {$EXTERNALSYM SERVICE_UNINSTALL_PENDING}
  SERVICE_INSTALLED         = $03;
  {$EXTERNALSYM SERVICE_INSTALLED}

// Bits 2,3 -- paused/active status

  SERVICE_PAUSE_STATE           = $0C;
  {$EXTERNALSYM SERVICE_PAUSE_STATE}
  LM20_SERVICE_ACTIVE           = $00;
  {$EXTERNALSYM LM20_SERVICE_ACTIVE}
  LM20_SERVICE_CONTINUE_PENDING = $04;
  {$EXTERNALSYM LM20_SERVICE_CONTINUE_PENDING}
  LM20_SERVICE_PAUSE_PENDING    = $08;
  {$EXTERNALSYM LM20_SERVICE_PAUSE_PENDING}
  LM20_SERVICE_PAUSED           = $0C;
  {$EXTERNALSYM LM20_SERVICE_PAUSED}

// Bit 4 -- uninstallable indication

  SERVICE_NOT_UNINSTALLABLE = $00;
  {$EXTERNALSYM SERVICE_NOT_UNINSTALLABLE}
  SERVICE_UNINSTALLABLE     = $10;
  {$EXTERNALSYM SERVICE_UNINSTALLABLE}

// Bit 5 -- pausable indication

  SERVICE_NOT_PAUSABLE = $00;
  {$EXTERNALSYM SERVICE_NOT_PAUSABLE}
  SERVICE_PAUSABLE     = $20;
  {$EXTERNALSYM SERVICE_PAUSABLE}

// Workstation service only:
// Bits 8,9,10 -- redirection paused/active

  SERVICE_REDIR_PAUSED       = $700;
  {$EXTERNALSYM SERVICE_REDIR_PAUSED}
  SERVICE_REDIR_DISK_PAUSED  = $100;
  {$EXTERNALSYM SERVICE_REDIR_DISK_PAUSED}
  SERVICE_REDIR_PRINT_PAUSED = $200;
  {$EXTERNALSYM SERVICE_REDIR_PRINT_PAUSED}
  SERVICE_REDIR_COMM_PAUSED  = $400;
  {$EXTERNALSYM SERVICE_REDIR_COMM_PAUSED}

//
//  Additional standard LAN Manager for MS-DOS services
//

  SERVICE_DOS_ENCRYPTION = WideString('ENCRYPT');
  {$EXTERNALSYM SERVICE_DOS_ENCRYPTION}

//
//  NetServiceControl opcodes.
//

  SERVICE_CTRL_INTERROGATE = 0;
  {$EXTERNALSYM SERVICE_CTRL_INTERROGATE}
  SERVICE_CTRL_PAUSE       = 1;
  {$EXTERNALSYM SERVICE_CTRL_PAUSE}
  SERVICE_CTRL_CONTINUE    = 2;
  {$EXTERNALSYM SERVICE_CTRL_CONTINUE}
  SERVICE_CTRL_UNINSTALL   = 3;
  {$EXTERNALSYM SERVICE_CTRL_UNINSTALL}

//
//  Workstation service only:  Bits used in the "arg" parameter
//  to NetServiceControl in conjunction with the opcode
//  SERVICE_CTRL_PAUSE or SERVICE_CTRL_CONTINUE, to pause or
//  continue redirection.
//

  SERVICE_CTRL_REDIR_DISK  = $1;
  {$EXTERNALSYM SERVICE_CTRL_REDIR_DISK}
  SERVICE_CTRL_REDIR_PRINT = $2;
  {$EXTERNALSYM SERVICE_CTRL_REDIR_PRINT}
  SERVICE_CTRL_REDIR_COMM  = $4;
  {$EXTERNALSYM SERVICE_CTRL_REDIR_COMM}

//
//  Values for svci1_code, and svci2_code when status
//  of the service is SERVICE_INSTALL_PENDING or
//  SERVICE_UNINSTALL_PENDING.
//  A service can optionally provide a hint to the installer
//  that the install is proceeding and how long to wait
//  (in 0.1 second increments) before querying status again.
//

  SERVICE_IP_NO_HINT  = $0;
  {$EXTERNALSYM SERVICE_IP_NO_HINT}
  SERVICE_CCP_NO_HINT = $0;
  {$EXTERNALSYM SERVICE_CCP_NO_HINT}

  SERVICE_IP_QUERY_HINT  = $10000;
  {$EXTERNALSYM SERVICE_IP_QUERY_HINT}
  SERVICE_CCP_QUERY_HINT = $10000;
  {$EXTERNALSYM SERVICE_CCP_QUERY_HINT}

//
// Mask for install proceeding checkpoint number
//

  SERVICE_IP_CHKPT_NUM  = $0FF;
  {$EXTERNALSYM SERVICE_IP_CHKPT_NUM}
  SERVICE_CCP_CHKPT_NUM = $0FF;
  {$EXTERNALSYM SERVICE_CCP_CHKPT_NUM}

//
// Mask for wait time hint before querying again
//

  SERVICE_IP_WAIT_TIME  = $0FF00;
  {$EXTERNALSYM SERVICE_IP_WAIT_TIME}
  SERVICE_CCP_WAIT_TIME = $0FF00;
  {$EXTERNALSYM SERVICE_CCP_WAIT_TIME}

//
// Shift count for building wait time _code values
//

  SERVICE_IP_WAITTIME_SHIFT   = 8;
  {$EXTERNALSYM SERVICE_IP_WAITTIME_SHIFT}
  SERVICE_NTIP_WAITTIME_SHIFT = 12;
  {$EXTERNALSYM SERVICE_NTIP_WAITTIME_SHIFT}

//
// Mask used for upper and lower portions of wait hint time.
//

  UPPER_HINT_MASK     = $0000FF00;
  {$EXTERNALSYM UPPER_HINT_MASK}
  LOWER_HINT_MASK     = $000000FF;
  {$EXTERNALSYM LOWER_HINT_MASK}
  UPPER_GET_HINT_MASK = $0FF00000;
  {$EXTERNALSYM UPPER_GET_HINT_MASK}
  LOWER_GET_HINT_MASK = $0000FF00;
  {$EXTERNALSYM LOWER_GET_HINT_MASK}
  SERVICE_NT_MAXTIME  = $0000FFFF;
  {$EXTERNALSYM SERVICE_NT_MAXTIME}
  SERVICE_RESRV_MASK  = $0001FFFF;
  {$EXTERNALSYM SERVICE_RESRV_MASK}
  SERVICE_MAXTIME     = $000000FF;
  {$EXTERNALSYM SERVICE_MAXTIME}

//
//  SERVICE_BASE is the base of service error codes,
//  chosen to avoid conflict with OS, redirector,
//  netapi, and errlog codes.
//
// Don't change the comments following the manifest constants without
// understanding how mapmsg works.
//

  SERVICE_BASE       = 3050;
  {$EXTERNALSYM SERVICE_BASE}
  SERVICE_UIC_NORMAL = 0;
  {$EXTERNALSYM SERVICE_UIC_NORMAL}

{*
 *  Uninstall codes, to be used in high byte of 'code' on final NetStatus,
 *  which sets the status to UNINSTALLED.
 *}

  SERVICE_UIC_BADPARMVAL = (SERVICE_BASE + 1);
  {$EXTERNALSYM SERVICE_UIC_BADPARMVAL}

{*
 * The Registry or the information you just typed includes an illegal
 * value for "%1".
 *}

  SERVICE_UIC_MISSPARM = (SERVICE_BASE + 2);
  {$EXTERNALSYM SERVICE_UIC_MISSPARM}

{*
 * The required parameter was not provided on the command
 * line or in the configuration file.
 *}

  SERVICE_UIC_UNKPARM = (SERVICE_BASE + 3);
  {$EXTERNALSYM SERVICE_UIC_UNKPARM}

{*
 * LAN Manager does not recognize "%1" as a valid option.
 *}

  SERVICE_UIC_RESOURCE = (SERVICE_BASE + 4);
  {$EXTERNALSYM SERVICE_UIC_RESOURCE}

{*
 * A request for resource could not be satisfied.
 *}

  SERVICE_UIC_CONFIG = (SERVICE_BASE + 5);
  {$EXTERNALSYM SERVICE_UIC_CONFIG}

{*
 * A problem exists with the system configuration.
 *}

  SERVICE_UIC_SYSTEM = (SERVICE_BASE + 6);
  {$EXTERNALSYM SERVICE_UIC_SYSTEM}

{*
 * A system error has occurred.
 *}

  SERVICE_UIC_INTERNAL = (SERVICE_BASE + 7);
  {$EXTERNALSYM SERVICE_UIC_INTERNAL}

{*
 * An internal consistency error has occurred.
 *}

  SERVICE_UIC_AMBIGPARM = (SERVICE_BASE + 8);
  {$EXTERNALSYM SERVICE_UIC_AMBIGPARM}

{*
 * The configuration file or the command line has an ambiguous option.
 *}

  SERVICE_UIC_DUPPARM = (SERVICE_BASE + 9);
  {$EXTERNALSYM SERVICE_UIC_DUPPARM}

{*
 * The configuration file or the command line has a duplicate parameter.
 *}

  SERVICE_UIC_KILL = (SERVICE_BASE + 10);
  {$EXTERNALSYM SERVICE_UIC_KILL}

{*
 * The service did not respond to control and was stopped with
 * the DosKillProc function.
 *}

  SERVICE_UIC_EXEC = (SERVICE_BASE + 11);
  {$EXTERNALSYM SERVICE_UIC_EXEC}

{*
 * An error occurred when attempting to run the service program.
 *}

  SERVICE_UIC_SUBSERV = (SERVICE_BASE + 12);
  {$EXTERNALSYM SERVICE_UIC_SUBSERV}

{*
 * The sub-service failed to start.
 *}

  SERVICE_UIC_CONFLPARM = (SERVICE_BASE + 13);
  {$EXTERNALSYM SERVICE_UIC_CONFLPARM}

{*
 * There is a conflict in the value or use of these options: %1.
 *}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -