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

Windows编程

开发平台:

Delphi

  1. {******************************************************************************}
  2. {                                                                       }
  3. { Winsock2 Namespace 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: nspapi.h, released June 2000. The original Pascal      }
  9. { code is: NspApi.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 JwaNspAPI;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "nspapi.h"'}
  47. {$HPPEMIT ''}
  48. {$I WINDEFINES.INC}
  49. interface
  50. uses
  51.   JwaWinType, JwaWinSock2;
  52. //
  53. // Service categories
  54. //
  55. const
  56.   SERVICE_RESOURCE = ($00000001);
  57.   {$EXTERNALSYM SERVICE_RESOURCE}
  58.   SERVICE_SERVICE  = ($00000002);
  59.   {$EXTERNALSYM SERVICE_SERVICE}
  60.   SERVICE_LOCAL    = ($00000004);
  61.   {$EXTERNALSYM SERVICE_LOCAL}
  62. //
  63. // Operation used when calling SetService()
  64. //
  65.   SERVICE_REGISTER    = ($00000001);
  66.   {$EXTERNALSYM SERVICE_REGISTER}
  67.   SERVICE_DEREGISTER  = ($00000002);
  68.   {$EXTERNALSYM SERVICE_DEREGISTER}
  69.   SERVICE_FLUSH       = ($00000003);
  70.   {$EXTERNALSYM SERVICE_FLUSH}
  71.   SERVICE_ADD_TYPE    = ($00000004);
  72.   {$EXTERNALSYM SERVICE_ADD_TYPE}
  73.   SERVICE_DELETE_TYPE = ($00000005);
  74.   {$EXTERNALSYM SERVICE_DELETE_TYPE}
  75. //
  76. // Flags that affect the operations above
  77. //
  78.   SERVICE_FLAG_DEFER = ($00000001);
  79.   {$EXTERNALSYM SERVICE_FLAG_DEFER}
  80.   SERVICE_FLAG_HARD  = ($00000002);
  81.   {$EXTERNALSYM SERVICE_FLAG_HARD}
  82. //
  83. // Used as input to GetService() for setting the dwProps parameter
  84. //
  85.   PROP_COMMENT      = ($00000001);
  86.   {$EXTERNALSYM PROP_COMMENT}
  87.   PROP_LOCALE       = ($00000002);
  88.   {$EXTERNALSYM PROP_LOCALE}
  89.   PROP_DISPLAY_HINT = ($00000004);
  90.   {$EXTERNALSYM PROP_DISPLAY_HINT}
  91.   PROP_VERSION      = ($00000008);
  92.   {$EXTERNALSYM PROP_VERSION}
  93.   PROP_START_TIME   = ($00000010);
  94.   {$EXTERNALSYM PROP_START_TIME}
  95.   PROP_MACHINE      = ($00000020);
  96.   {$EXTERNALSYM PROP_MACHINE}
  97.   PROP_ADDRESSES    = ($00000100);
  98.   {$EXTERNALSYM PROP_ADDRESSES}
  99.   PROP_SD           = ($00000200);
  100.   {$EXTERNALSYM PROP_SD}
  101.   PROP_ALL          = DWORD($80000000);
  102.   {$EXTERNALSYM PROP_ALL}
  103. //
  104. // Flags that describe attributes of Service Addresses
  105. //
  106.   SERVICE_ADDRESS_FLAG_RPC_CN = ($00000001);
  107.   {$EXTERNALSYM SERVICE_ADDRESS_FLAG_RPC_CN}
  108.   SERVICE_ADDRESS_FLAG_RPC_DG = ($00000002);
  109.   {$EXTERNALSYM SERVICE_ADDRESS_FLAG_RPC_DG}
  110.   SERVICE_ADDRESS_FLAG_RPC_NB = ($00000004);
  111.   {$EXTERNALSYM SERVICE_ADDRESS_FLAG_RPC_NB}
  112. //
  113. // Name Spaces
  114. //
  115.   NS_DEFAULT = (0);
  116.   {$EXTERNALSYM NS_DEFAULT}
  117.   NS_SAP         = (1);
  118.   {$EXTERNALSYM NS_SAP}
  119.   NS_NDS         = (2);
  120.   {$EXTERNALSYM NS_NDS}
  121.   NS_PEER_BROWSE = (3);
  122.   {$EXTERNALSYM NS_PEER_BROWSE}
  123.   NS_TCPIP_LOCAL = (10);
  124.   {$EXTERNALSYM NS_TCPIP_LOCAL}
  125.   NS_TCPIP_HOSTS = (11);
  126.   {$EXTERNALSYM NS_TCPIP_HOSTS}
  127.   NS_DNS         = (12);
  128.   {$EXTERNALSYM NS_DNS}
  129.   NS_NETBT       = (13);
  130.   {$EXTERNALSYM NS_NETBT}
  131.   NS_WINS        = (14);
  132.   {$EXTERNALSYM NS_WINS}
  133.   NS_NBP = (20);
  134.   {$EXTERNALSYM NS_NBP}
  135.   NS_MS   = (30);
  136.   {$EXTERNALSYM NS_MS}
  137.   NS_STDA = (31);
  138.   {$EXTERNALSYM NS_STDA}
  139.   NS_NTDS = (32);
  140.   {$EXTERNALSYM NS_NTDS}
  141.   NS_X500 = (40);
  142.   {$EXTERNALSYM NS_X500}
  143.   NS_NIS  = (41);
  144.   {$EXTERNALSYM NS_NIS}
  145.   NS_VNS = (50);
  146.   {$EXTERNALSYM NS_VNS}
  147. //
  148. // Name space attributes.
  149. //
  150.   NSTYPE_HIERARCHICAL = ($00000001);
  151.   {$EXTERNALSYM NSTYPE_HIERARCHICAL}
  152.   NSTYPE_DYNAMIC      = ($00000002);
  153.   {$EXTERNALSYM NSTYPE_DYNAMIC}
  154.   NSTYPE_ENUMERABLE   = ($00000004);
  155.   {$EXTERNALSYM NSTYPE_ENUMERABLE}
  156.   NSTYPE_WORKGROUP    = ($00000008);
  157.   {$EXTERNALSYM NSTYPE_WORKGROUP}
  158. //
  159. // Transport attributes.
  160. //
  161.   XP_CONNECTIONLESS       = ($00000001);
  162.   {$EXTERNALSYM XP_CONNECTIONLESS}
  163.   XP_GUARANTEED_DELIVERY  = ($00000002);
  164.   {$EXTERNALSYM XP_GUARANTEED_DELIVERY}
  165.   XP_GUARANTEED_ORDER     = ($00000004);
  166.   {$EXTERNALSYM XP_GUARANTEED_ORDER}
  167.   XP_MESSAGE_ORIENTED     = ($00000008);
  168.   {$EXTERNALSYM XP_MESSAGE_ORIENTED}
  169.   XP_PSEUDO_STREAM        = ($00000010);
  170.   {$EXTERNALSYM XP_PSEUDO_STREAM}
  171.   XP_GRACEFUL_CLOSE       = ($00000020);
  172.   {$EXTERNALSYM XP_GRACEFUL_CLOSE}
  173.   XP_EXPEDITED_DATA       = ($00000040);
  174.   {$EXTERNALSYM XP_EXPEDITED_DATA}
  175.   XP_CONNECT_DATA         = ($00000080);
  176.   {$EXTERNALSYM XP_CONNECT_DATA}
  177.   XP_DISCONNECT_DATA      = ($00000100);
  178.   {$EXTERNALSYM XP_DISCONNECT_DATA}
  179.   XP_SUPPORTS_BROADCAST   = ($00000200);
  180.   {$EXTERNALSYM XP_SUPPORTS_BROADCAST}
  181.   XP_SUPPORTS_MULTICAST   = ($00000400);
  182.   {$EXTERNALSYM XP_SUPPORTS_MULTICAST}
  183.   XP_BANDWIDTH_ALLOCATION = ($00000800);
  184.   {$EXTERNALSYM XP_BANDWIDTH_ALLOCATION}
  185.   XP_FRAGMENTATION        = ($00001000);
  186.   {$EXTERNALSYM XP_FRAGMENTATION}
  187.   XP_ENCRYPTS             = ($00002000);
  188.   {$EXTERNALSYM XP_ENCRYPTS}
  189. //
  190. // Resolution flags for GetAddressByName().
  191. //
  192.   RES_SOFT_SEARCH   = ($00000001);
  193.   {$EXTERNALSYM RES_SOFT_SEARCH}
  194.   RES_FIND_MULTIPLE = ($00000002);
  195.   {$EXTERNALSYM RES_FIND_MULTIPLE}
  196.   RES_SERVICE       = ($00000004);
  197.   {$EXTERNALSYM RES_SERVICE}
  198. //
  199. // Well known value names for Service Types
  200. //
  201.   SERVICE_TYPE_VALUE_SAPIDA = 'SapId';
  202.   {$EXTERNALSYM SERVICE_TYPE_VALUE_SAPIDA}
  203.   SERVICE_TYPE_VALUE_SAPIDW = WideString('SapId');
  204.   {$EXTERNALSYM SERVICE_TYPE_VALUE_SAPIDW}
  205.   SERVICE_TYPE_VALUE_CONNA = 'ConnectionOriented';
  206.   {$EXTERNALSYM SERVICE_TYPE_VALUE_CONNA}
  207.   SERVICE_TYPE_VALUE_CONNW = WideString('ConnectionOriented');
  208.   {$EXTERNALSYM SERVICE_TYPE_VALUE_CONNW}
  209.   SERVICE_TYPE_VALUE_TCPPORTA = 'TcpPort';
  210.   {$EXTERNALSYM SERVICE_TYPE_VALUE_TCPPORTA}
  211.   SERVICE_TYPE_VALUE_TCPPORTW = WideString('TcpPort');
  212.   {$EXTERNALSYM SERVICE_TYPE_VALUE_TCPPORTW}
  213.   SERVICE_TYPE_VALUE_UDPPORTA = 'UdpPort';
  214.   {$EXTERNALSYM SERVICE_TYPE_VALUE_UDPPORTA}
  215.   SERVICE_TYPE_VALUE_UDPPORTW = WideString('UdpPort');
  216.   {$EXTERNALSYM SERVICE_TYPE_VALUE_UDPPORTW}
  217. {$IFDEF UNICODE}
  218.   SERVICE_TYPE_VALUE_SAPID   = SERVICE_TYPE_VALUE_SAPIDW;
  219.   {$EXTERNALSYM SERVICE_TYPE_VALUE_SAPID}
  220.   SERVICE_TYPE_VALUE_CONN    = SERVICE_TYPE_VALUE_CONNW;
  221.   {$EXTERNALSYM SERVICE_TYPE_VALUE_CONN}
  222.   SERVICE_TYPE_VALUE_TCPPORT = SERVICE_TYPE_VALUE_TCPPORTW;
  223.   {$EXTERNALSYM SERVICE_TYPE_VALUE_TCPPORT}
  224.   SERVICE_TYPE_VALUE_UDPPORT = SERVICE_TYPE_VALUE_UDPPORTW;
  225.   {$EXTERNALSYM SERVICE_TYPE_VALUE_UDPPORT}
  226. {$ELSE}
  227.   SERVICE_TYPE_VALUE_SAPID   = SERVICE_TYPE_VALUE_SAPIDA;
  228.   {$EXTERNALSYM SERVICE_TYPE_VALUE_SAPID}
  229.   SERVICE_TYPE_VALUE_CONN    = SERVICE_TYPE_VALUE_CONNA;
  230.   {$EXTERNALSYM SERVICE_TYPE_VALUE_CONN}
  231.   SERVICE_TYPE_VALUE_TCPPORT = SERVICE_TYPE_VALUE_TCPPORTA;
  232.   {$EXTERNALSYM SERVICE_TYPE_VALUE_TCPPORT}
  233.   SERVICE_TYPE_VALUE_UDPPORT = SERVICE_TYPE_VALUE_UDPPORTA;
  234.   {$EXTERNALSYM SERVICE_TYPE_VALUE_UDPPORT}
  235. {$ENDIF}
  236. //
  237. // status flags returned by SetService
  238. //
  239.   SET_SERVICE_PARTIAL_SUCCESS = ($00000001);
  240.   {$EXTERNALSYM SET_SERVICE_PARTIAL_SUCCESS}
  241. //
  242. // Name Space Information
  243. //
  244. type
  245.   _NS_INFOA = record
  246.     dwNameSpace: DWORD;
  247.     dwNameSpaceFlags: DWORD;
  248.     lpNameSpace: LPSTR;
  249.   end;
  250.   {$EXTERNALSYM _NS_INFOA}
  251.   NS_INFOA = _NS_INFOA;
  252.   {$EXTERNALSYM NS_INFOA}
  253.   PNS_INFOA = ^NS_INFOA;
  254.   {$EXTERNALSYM PNS_INFOA}
  255.   LPNS_INFOA = ^NS_INFOA;
  256.   {$EXTERNALSYM LPNS_INFOA}
  257.   TNsInfoA = NS_INFOA;
  258.   PNsInfoA = LPNS_INFOA;
  259. //
  260. // Name Space Information
  261. //
  262.   _NS_INFOW = record
  263.     dwNameSpace: DWORD;
  264.     dwNameSpaceFlags: DWORD;
  265.     lpNameSpace: LPWSTR;
  266.   end;
  267.   {$EXTERNALSYM _NS_INFOW}
  268.   NS_INFOW = _NS_INFOW;
  269.   {$EXTERNALSYM NS_INFOW}
  270.   PNS_INFOW = ^NS_INFOW;
  271.   {$EXTERNALSYM PNS_INFOW}
  272.   LPNS_INFOW = ^NS_INFOW;
  273.   {$EXTERNALSYM LPNS_INFOW}
  274.   TNsInfoW = NS_INFOW;
  275.   PNsInfoW = LPNS_INFOW;
  276. {$IFDEF UNICODE}
  277.   NS_INFO = NS_INFOW;
  278.   {$EXTERNALSYM NS_INFO}
  279.   PNS_INFO = PNS_INFOW;
  280.   {$EXTERNALSYM PNS_INFO}
  281.   LPNS_INFO = LPNS_INFOW;
  282.   {$EXTERNALSYM LPNS_INFO}
  283.   TNsInfo = TNsInfoW;
  284.   PNsInfo = PNsInfoW;
  285. {$ELSE}
  286.   NS_INFO = NS_INFOA;
  287.   {$EXTERNALSYM NS_INFO}
  288.   PNS_INFO = PNS_INFOA;
  289.   {$EXTERNALSYM PNS_INFO}
  290.   LPNS_INFO = LPNS_INFOA;
  291.   {$EXTERNALSYM LPNS_INFO}
  292.   TNsInfo = TNsInfoA;
  293.   PNsInfo = PNsInfoA;
  294. {$ENDIF}
  295. //
  296. // Service Type Values. The structures are used to define named Service
  297. // Type specific values. This structure is self relative and has no pointers.
  298. //
  299.   LPSERVICE_TYPE_VALUE = ^SERVICE_TYPE_VALUE;
  300.   {$EXTERNALSYM LPSERVICE_TYPE_VALUE}
  301.   PSERVICE_TYPE_VALUE = ^SERVICE_TYPE_VALUE;
  302.   {$EXTERNALSYM PSERVICE_TYPE_VALUE}
  303.   _SERVICE_TYPE_VALUE = record
  304.     dwNameSpace: DWORD;
  305.     dwValueType: DWORD;
  306.     dwValueSize: DWORD;
  307.     dwValueNameOffset: DWORD;
  308.     dwValueOffset: DWORD;
  309.   end;
  310.   {$EXTERNALSYM _SERVICE_TYPE_VALUE}
  311.   SERVICE_TYPE_VALUE = _SERVICE_TYPE_VALUE;
  312.   {$EXTERNALSYM SERVICE_TYPE_VALUE}
  313.   TServiceTypeValue = SERVICE_TYPE_VALUE;
  314.   PServiceTypeValue = LPSERVICE_TYPE_VALUE;
  315. //
  316. // An absolute version of above. This structure does contain pointers.
  317. //
  318.   LPSERVICE_TYPE_VALUE_ABSA = ^SERVICE_TYPE_VALUE_ABSA;
  319.   {$EXTERNALSYM LPSERVICE_TYPE_VALUE_ABSA}
  320.   PSERVICE_TYPE_VALUE_ABSA = ^SERVICE_TYPE_VALUE_ABSA;
  321.   {$EXTERNALSYM PSERVICE_TYPE_VALUE_ABSA}
  322.   _SERVICE_TYPE_VALUE_ABSA = record
  323.     dwNameSpace: DWORD;
  324.     dwValueType: DWORD;
  325.     dwValueSize: DWORD;
  326.     lpValueName: LPSTR;
  327.     lpValue: LPVOID;
  328.   end;
  329.   {$EXTERNALSYM _SERVICE_TYPE_VALUE_ABSA}
  330.   SERVICE_TYPE_VALUE_ABSA = _SERVICE_TYPE_VALUE_ABSA;
  331.   {$EXTERNALSYM SERVICE_TYPE_VALUE_ABSA}
  332.   TServiceTypeValueAbsA = SERVICE_TYPE_VALUE_ABSA;
  333.   PServiceTypeValueAbsA = LPSERVICE_TYPE_VALUE_ABSA;
  334. //
  335. // An absolute version of above. This structure does contain pointers.
  336. //
  337.   LPSERVICE_TYPE_VALUE_ABSW = ^SERVICE_TYPE_VALUE_ABSW;
  338.   {$EXTERNALSYM LPSERVICE_TYPE_VALUE_ABSW}
  339.   PSERVICE_TYPE_VALUE_ABSW = ^SERVICE_TYPE_VALUE_ABSW;
  340.   {$EXTERNALSYM PSERVICE_TYPE_VALUE_ABSW}
  341.   _SERVICE_TYPE_VALUE_ABSW = record
  342.     dwNameSpace: DWORD;
  343.     dwValueType: DWORD;
  344.     dwValueSize: DWORD;
  345.     lpValueName: LPWSTR;
  346.     lpValue: LPVOID;
  347.   end;
  348.   {$EXTERNALSYM _SERVICE_TYPE_VALUE_ABSW}
  349.   SERVICE_TYPE_VALUE_ABSW = _SERVICE_TYPE_VALUE_ABSW;
  350.   {$EXTERNALSYM SERVICE_TYPE_VALUE_ABSW}
  351.   TServiceTypeValueAbsW = SERVICE_TYPE_VALUE_ABSW;
  352.   PServiceTypeValueAbsW = LPSERVICE_TYPE_VALUE_ABSW;
  353. {$IFDEF UNICODE}
  354.   SERVICE_TYPE_VALUE_ABS = SERVICE_TYPE_VALUE_ABSW;
  355.   {$EXTERNALSYM SERVICE_TYPE_VALUE_ABS}
  356.   PSERVICE_TYPE_VALUE_ABS = PSERVICE_TYPE_VALUE_ABSW;
  357.   {$EXTERNALSYM PSERVICE_TYPE_VALUE_ABS}
  358.   LPSERVICE_TYPE_VALUE_ABS = LPSERVICE_TYPE_VALUE_ABSW;
  359.   {$EXTERNALSYM LPSERVICE_TYPE_VALUE_ABS}
  360.   TServiceTypeValueAbs = TServiceTypeValueAbsW;
  361.   PServiceTypeValueAbs = PServiceTypeValueAbsW;
  362. {$ELSE}
  363.   SERVICE_TYPE_VALUE_ABS = SERVICE_TYPE_VALUE_ABSA;
  364.   {$EXTERNALSYM SERVICE_TYPE_VALUE_ABS}
  365.   PSERVICE_TYPE_VALUE_ABS = PSERVICE_TYPE_VALUE_ABSA;
  366.   {$EXTERNALSYM PSERVICE_TYPE_VALUE_ABS}
  367.   LPSERVICE_TYPE_VALUE_ABS = LPSERVICE_TYPE_VALUE_ABSA;
  368.   {$EXTERNALSYM LPSERVICE_TYPE_VALUE_ABS}
  369.   TServiceTypeValueAbs = TServiceTypeValueAbsA;
  370.   PServiceTypeValueAbs = PServiceTypeValueAbsA;
  371. {$ENDIF}
  372. //
  373. // Service Type Information. Contains the name of the Service Type and
  374. // and an array of SERVICE_NS_TYPE_VALUE structures. This structure is self
  375. // relative and has no pointers in it.
  376. //
  377.   LPSERVICE_TYPE_INFO = ^SERVICE_TYPE_INFO;
  378.   {$EXTERNALSYM LPSERVICE_TYPE_INFO}
  379.   PSERVICE_TYPE_INFO = ^SERVICE_TYPE_INFO;
  380.   {$EXTERNALSYM PSERVICE_TYPE_INFO}
  381.   _SERVICE_TYPE_INFO = record
  382.     dwTypeNameOffset: DWORD;
  383.     dwValueCount: DWORD;
  384.     Values: array [0..0] of SERVICE_TYPE_VALUE;
  385.   end;
  386.   {$EXTERNALSYM _SERVICE_TYPE_INFO}
  387.   SERVICE_TYPE_INFO = _SERVICE_TYPE_INFO;
  388.   {$EXTERNALSYM SERVICE_TYPE_INFO}
  389.   TServiceTypeInfo = SERVICE_TYPE_INFO;
  390.   PServiceTypeInfo = LPSERVICE_TYPE_INFO;
  391.   LPSERVICE_TYPE_INFO_ABSA = ^SERVICE_TYPE_INFO_ABSA;
  392.   {$EXTERNALSYM LPSERVICE_TYPE_INFO_ABSA}
  393.   PSERVICE_TYPE_INFO_ABSA = ^SERVICE_TYPE_INFO_ABSA;
  394.   {$EXTERNALSYM PSERVICE_TYPE_INFO_ABSA}
  395.   _SERVICE_TYPE_INFO_ABSA = record
  396.     lpTypeName: LPSTR;
  397.     dwValueCount: DWORD;
  398.     Values: array [0..0] of SERVICE_TYPE_VALUE_ABSA;
  399.   end;
  400.   {$EXTERNALSYM _SERVICE_TYPE_INFO_ABSA}
  401.   SERVICE_TYPE_INFO_ABSA = _SERVICE_TYPE_INFO_ABSA;
  402.   {$EXTERNALSYM SERVICE_TYPE_INFO_ABSA}
  403.   TServiceTypeInfoAbsA = SERVICE_TYPE_INFO_ABSA;
  404.   PServiceTypeInfoAbsA = PSERVICE_TYPE_INFO_ABSA;
  405.   LPSERVICE_TYPE_INFO_ABSW = ^SERVICE_TYPE_INFO_ABSW;
  406.   {$EXTERNALSYM LPSERVICE_TYPE_INFO_ABSW}
  407.   PSERVICE_TYPE_INFO_ABSW = ^SERVICE_TYPE_INFO_ABSW;
  408.   {$EXTERNALSYM PSERVICE_TYPE_INFO_ABSW}
  409.   _SERVICE_TYPE_INFO_ABSW = record
  410.     lpTypeName: LPWSTR;
  411.     dwValueCount: DWORD;
  412.     Values: array [0..0] of SERVICE_TYPE_VALUE_ABSW;
  413.   end;
  414.   {$EXTERNALSYM _SERVICE_TYPE_INFO_ABSW}
  415.   SERVICE_TYPE_INFO_ABSW = _SERVICE_TYPE_INFO_ABSW;
  416.   {$EXTERNALSYM SERVICE_TYPE_INFO_ABSW}
  417.   TServiceTypeInfoAbsW = SERVICE_TYPE_INFO_ABSW;
  418.   PServiceTypeInfoAbsW = LPSERVICE_TYPE_INFO_ABSW;
  419. {$IFDEF UNICODE}
  420.   SERVICE_TYPE_INFO_ABS = SERVICE_TYPE_INFO_ABSW;
  421.   {$EXTERNALSYM SERVICE_TYPE_INFO_ABS}
  422.   PSERVICE_TYPE_INFO_ABS = PSERVICE_TYPE_INFO_ABSW;
  423.   {$EXTERNALSYM PSERVICE_TYPE_INFO_ABS}
  424.   LPSERVICE_TYPE_INFO_ABS = LPSERVICE_TYPE_INFO_ABSW;
  425.   {$EXTERNALSYM LPSERVICE_TYPE_INFO_ABS}
  426.   TServiceTypeInfoAbs = TServiceTypeInfoAbsW;
  427.   PServiceTypeInfoAbs = PServiceTypeInfoAbsW;
  428. {$ELSE}
  429.   SERVICE_TYPE_INFO_ABS = SERVICE_TYPE_INFO_ABSA;
  430.   {$EXTERNALSYM SERVICE_TYPE_INFO_ABS}
  431.   PSERVICE_TYPE_INFO_ABS = PSERVICE_TYPE_INFO_ABSA;
  432.   {$EXTERNALSYM PSERVICE_TYPE_INFO_ABS}
  433.   LPSERVICE_TYPE_INFO_ABS = LPSERVICE_TYPE_INFO_ABSA;
  434.   {$EXTERNALSYM LPSERVICE_TYPE_INFO_ABS}
  435.   TServiceTypeInfoAbs = TServiceTypeInfoAbsA;
  436.   PServiceTypeInfoAbs = PServiceTypeInfoAbsA;
  437. {$ENDIF}
  438. //
  439. // A Single Address definition.
  440. //
  441.   LPSERVICE_ADDRESS = ^SERVICE_ADDRESS;
  442.   {$EXTERNALSYM LPSERVICE_ADDRESS}
  443.   PSERVICE_ADDRESS = ^SERVICE_ADDRESS;
  444.   {$EXTERNALSYM PSERVICE_ADDRESS}
  445.   _SERVICE_ADDRESS = record
  446.     dwAddressType: DWORD;
  447.     dwAddressFlags: DWORD;
  448.     dwAddressLength: DWORD;
  449.     dwPrincipalLength: DWORD;
  450.     lpAddress: LPBYTE;
  451.     lpPrincipal: LPBYTE;
  452.   end;
  453.   {$EXTERNALSYM _SERVICE_ADDRESS}
  454.   SERVICE_ADDRESS = _SERVICE_ADDRESS;
  455.   {$EXTERNALSYM SERVICE_ADDRESS}
  456.   TServiceAddress = SERVICE_ADDRESS;
  457.   PServiceAddress = LPSERVICE_ADDRESS;
  458. //
  459. // Addresses used by the service. Contains array of SERVICE_ADDRESS.
  460. //
  461.   LPSERVICE_ADDRESSES = ^SERVICE_ADDRESSES;
  462.   {$EXTERNALSYM LPSERVICE_ADDRESSES}
  463.   PSERVICE_ADDRESSES = ^SERVICE_ADDRESSES;
  464.   {$EXTERNALSYM PSERVICE_ADDRESSES}
  465.   _SERVICE_ADDRESSES = record
  466.     dwAddressCount: DWORD;
  467.     Addresses: array [0..0] of SERVICE_ADDRESS;
  468.   end;
  469.   {$EXTERNALSYM _SERVICE_ADDRESSES}
  470.   SERVICE_ADDRESSES = _SERVICE_ADDRESSES;
  471.   {$EXTERNALSYM SERVICE_ADDRESSES}
  472.   TServiceAddresses = SERVICE_ADDRESSES;
  473.   PServiceAddresses = PSERVICE_ADDRESSES;
  474. //
  475. // Service Information.
  476. //
  477.   LPSERVICE_INFOA = ^SERVICE_INFOA;
  478.   {$EXTERNALSYM LPSERVICE_INFOA}
  479.   PSERVICE_INFOA = ^SERVICE_INFOA;
  480.   {$EXTERNALSYM PSERVICE_INFOA}
  481.   _SERVICE_INFOA = record
  482.     lpServiceType: PGUID;
  483.     lpServiceName: LPSTR;
  484.     lpComment: LPSTR;
  485.     lpLocale: LPSTR;
  486.     dwDisplayHint: DWORD;
  487.     dwVersion: DWORD;
  488.     dwTime: DWORD;
  489.     lpMachineName: LPSTR;
  490.     lpServiceAddress: LPSERVICE_ADDRESSES;
  491.     ServiceSpecificInfo: BLOB;
  492.   end;
  493.   {$EXTERNALSYM _SERVICE_INFOA}
  494.   SERVICE_INFOA = _SERVICE_INFOA;
  495.   {$EXTERNALSYM SERVICE_INFOA}
  496.   TServiceInfoA = SERVICE_INFOA;
  497.   PServiceInfoA = PSERVICE_INFOA;
  498. //
  499. // Service Information.
  500. //
  501.   LPSERVICE_INFOW = ^SERVICE_INFOW;
  502.   {$EXTERNALSYM LPSERVICE_INFOW}
  503.   PSERVICE_INFOW = ^SERVICE_INFOW;
  504.   {$EXTERNALSYM PSERVICE_INFOW}
  505.   _SERVICE_INFOW = record
  506.     lpServiceType: PGUID;
  507.     lpServiceName: LPWSTR;
  508.     lpComment: LPWSTR;
  509.     lpLocale: LPWSTR;
  510.     dwDisplayHint: DWORD;
  511.     dwVersion: DWORD;
  512.     dwTime: DWORD;
  513.     lpMachineName: LPWSTR;
  514.     lpServiceAddress: LPSERVICE_ADDRESSES;
  515.     ServiceSpecificInfo: BLOB;
  516.   end;
  517.   {$EXTERNALSYM _SERVICE_INFOW}
  518.   SERVICE_INFOW = _SERVICE_INFOW;
  519.   {$EXTERNALSYM SERVICE_INFOW}
  520.   TServiceInfoW = SERVICE_INFOW;
  521.   PServiceInfoW = PSERVICE_INFOW;
  522. {$IFDEF UNICODE}
  523.   SERVICE_INFO = SERVICE_INFOW;
  524.   {$EXTERNALSYM SERVICE_INFO}
  525.   PSERVICE_INFO = PSERVICE_INFOW;
  526.   {$EXTERNALSYM PSERVICE_INFO}
  527.   LPSERVICE_INFO = LPSERVICE_INFOW;
  528.   {$EXTERNALSYM LPSERVICE_INFO}
  529.   TServiceInfo = TServiceInfoW;
  530.   PServiceInfo = PServiceInfoW;
  531. {$ELSE}
  532.   SERVICE_INFO = SERVICE_INFOA;
  533.   {$EXTERNALSYM SERVICE_INFO}
  534.   PSERVICE_INFO = PSERVICE_INFOA;
  535.   {$EXTERNALSYM PSERVICE_INFO}
  536.   LPSERVICE_INFO = LPSERVICE_INFOA;
  537.   {$EXTERNALSYM LPSERVICE_INFO}
  538.   TServiceInfo = TServiceInfoA;
  539.   PServiceInfo = PServiceInfoA;
  540. {$ENDIF}
  541. //
  542. // Name Space & Service Information
  543. //
  544.   LPNS_SERVICE_INFOA = ^NS_SERVICE_INFOA;
  545.   {$EXTERNALSYM LPNS_SERVICE_INFOA}
  546.   PNS_SERVICE_INFOA = ^NS_SERVICE_INFOA;
  547.   {$EXTERNALSYM PNS_SERVICE_INFOA}
  548.   _NS_SERVICE_INFOA = record
  549.     dwNameSpace: DWORD;
  550.     ServiceInfo: SERVICE_INFOA;
  551.   end;
  552.   {$EXTERNALSYM _NS_SERVICE_INFOA}
  553.   NS_SERVICE_INFOA = _NS_SERVICE_INFOA;
  554.   {$EXTERNALSYM NS_SERVICE_INFOA}
  555.   TNsServiceInfoA = NS_SERVICE_INFOA;
  556.   PNsServiceInfoA = LPNS_SERVICE_INFOA;
  557. //
  558. // Name Space & Service Information
  559. //
  560.   LPNS_SERVICE_INFOW = ^NS_SERVICE_INFOW;
  561.   {$EXTERNALSYM LPNS_SERVICE_INFOW}
  562.   PNS_SERVICE_INFOW = ^NS_SERVICE_INFOW;
  563.   {$EXTERNALSYM PNS_SERVICE_INFOW}
  564.   _NS_SERVICE_INFOW = record
  565.     dwNameSpace: DWORD;
  566.     ServiceInfo: SERVICE_INFOW;
  567.   end;
  568.   {$EXTERNALSYM _NS_SERVICE_INFOW}
  569.   NS_SERVICE_INFOW = _NS_SERVICE_INFOW;
  570.   {$EXTERNALSYM NS_SERVICE_INFOW}
  571.   TNsServiceInfoW = NS_SERVICE_INFOW;
  572.   PNsServiceInfoW = LPNS_SERVICE_INFOW;
  573. {$IFDEF UNICODE}
  574.   NS_SERVICE_INFO = NS_SERVICE_INFOW;
  575.   {$EXTERNALSYM NS_SERVICE_INFO}
  576.   PNS_SERVICE_INFO = PNS_SERVICE_INFOW;
  577.   {$EXTERNALSYM PNS_SERVICE_INFO}
  578.   LPNS_SERVICE_INFO = LPNS_SERVICE_INFOW;
  579.   {$EXTERNALSYM LPNS_SERVICE_INFO}
  580.   TNsServiceInfo = TNsServiceInfoW;
  581.   PNsServiceInfo = PNsServiceInfoW;
  582. {$ELSE}
  583.   NS_SERVICE_INFO = NS_SERVICE_INFOA;
  584.   {$EXTERNALSYM NS_SERVICE_INFO}
  585.   PNS_SERVICE_INFO = PNS_SERVICE_INFOA;
  586.   {$EXTERNALSYM PNS_SERVICE_INFO}
  587.   LPNS_SERVICE_INFO = LPNS_SERVICE_INFOA;
  588.   {$EXTERNALSYM LPNS_SERVICE_INFO}
  589.   TNsServiceInfo = TNsServiceInfoA;
  590.   PNsServiceInfo = PNsServiceInfoA;
  591. {$ENDIF}
  592. //
  593. // SockAddr Information
  594. //
  595.   LPSOCKET_ADDRESS = ^SOCKET_ADDRESS;
  596.   {$EXTERNALSYM LPSOCKET_ADDRESS}
  597.   PSOCKET_ADDRESS = ^SOCKET_ADDRESS;
  598.   {$EXTERNALSYM PSOCKET_ADDRESS}
  599.   _SOCKET_ADDRESS = record
  600.     lpSockaddr: LPSOCKADDR;
  601.     iSockaddrLength: Integer;
  602.   end;
  603.   {$EXTERNALSYM _SOCKET_ADDRESS}
  604.   SOCKET_ADDRESS = _SOCKET_ADDRESS;
  605.   {$EXTERNALSYM SOCKET_ADDRESS}
  606.   TSocketAddress = SOCKET_ADDRESS;
  607.   PSocketAddress = PSOCKET_ADDRESS;
  608. //
  609. // CSAddr Information
  610. //
  611.   LPCSADDR_INFO = ^CSADDR_INFO;
  612.   {$EXTERNALSYM LPCSADDR_INFO}
  613.   PCSADDR_INFO = ^CSADDR_INFO;
  614.   {$EXTERNALSYM PCSADDR_INFO}
  615.   _CSADDR_INFO = record
  616.     LocalAddr: SOCKET_ADDRESS;
  617.     RemoteAddr: SOCKET_ADDRESS;
  618.     iSocketType: Integer;
  619.     iProtocol: Integer;
  620.   end;
  621.   {$EXTERNALSYM _CSADDR_INFO}
  622.   CSADDR_INFO = _CSADDR_INFO;
  623.   {$EXTERNALSYM CSADDR_INFO}
  624.   TCsAddrInfo = CSADDR_INFO;
  625.   PCsAddrInfo = LPCSADDR_INFO;
  626. //
  627. // Protocol Information
  628. //
  629.   LPPROTOCOL_INFOA = ^PROTOCOL_INFOA;
  630.   {$EXTERNALSYM LPPROTOCOL_INFOA}
  631.   PPROTOCOL_INFOA = ^PROTOCOL_INFOA;
  632.   {$EXTERNALSYM PPROTOCOL_INFOA}
  633.   _PROTOCOL_INFOA = record
  634.     dwServiceFlags: DWORD;
  635.     iAddressFamily: Integer;
  636.     iMaxSockAddr: Integer;
  637.     iMinSockAddr: Integer;
  638.     iSocketType: Integer;
  639.     iProtocol: Integer;
  640.     dwMessageSize: DWORD;
  641.     lpProtocol: LPSTR;
  642.   end;
  643.   {$EXTERNALSYM _PROTOCOL_INFOA}
  644.   PROTOCOL_INFOA = _PROTOCOL_INFOA;
  645.   {$EXTERNALSYM PROTOCOL_INFOA}
  646.   TProtocolInfoA = PROTOCOL_INFOA;
  647.   PProtocolInfoA = LPPROTOCOL_INFOA;
  648. //
  649. // Protocol Information
  650. //
  651.   LPPROTOCOL_INFOW = ^PROTOCOL_INFOW;
  652.   {$EXTERNALSYM LPPROTOCOL_INFOW}
  653.   PPROTOCOL_INFOW = ^PROTOCOL_INFOW;
  654.   {$EXTERNALSYM PPROTOCOL_INFOW}
  655.   _PROTOCOL_INFOW = record
  656.     dwServiceFlags: DWORD;
  657.     iAddressFamily: Integer;
  658.     iMaxSockAddr: Integer;
  659.     iMinSockAddr: Integer;
  660.     iSocketType: Integer;
  661.     iProtocol: Integer;
  662.     dwMessageSize: DWORD;
  663.     lpProtocol: LPWSTR;
  664.   end;
  665.   {$EXTERNALSYM _PROTOCOL_INFOW}
  666.   PROTOCOL_INFOW = _PROTOCOL_INFOW;
  667.   {$EXTERNALSYM PROTOCOL_INFOW}
  668.   TProtocolInfoW = PROTOCOL_INFOW;
  669.   PProtocolInfoW = LPPROTOCOL_INFOW;
  670. {$IFDEF UNICODE}
  671.   PROTOCOL_INFO = PROTOCOL_INFOW;
  672.   {$EXTERNALSYM PROTOCOL_INFO}
  673.   PPROTOCOL_INFO = PPROTOCOL_INFOW;
  674.   {$EXTERNALSYM PPROTOCOL_INFO}
  675.   LPPROTOCOL_INFO = LPPROTOCOL_INFOW;
  676.   {$EXTERNALSYM LPPROTOCOL_INFO}
  677.   TProtocolInfo = TProtocolInfoW;
  678.   PProtocolInfo = PProtocolInfoW;
  679. {$ELSE}
  680.   PROTOCOL_INFO = PROTOCOL_INFOA;
  681.   {$EXTERNALSYM PROTOCOL_INFO}
  682.   PPROTOCOL_INFO = PPROTOCOL_INFOA;
  683.   {$EXTERNALSYM PPROTOCOL_INFO}
  684.   LPPROTOCOL_INFO = LPPROTOCOL_INFOA;
  685.   {$EXTERNALSYM LPPROTOCOL_INFO}
  686.   TProtocolInfo = TProtocolInfoA;
  687.   PProtocolInfo = PProtocolInfoA;
  688. {$ENDIF}
  689. //
  690. // NETRESOURCE2 Structure
  691. //
  692.   LPNETRESOURCE2A = ^NETRESOURCE2A;
  693.   {$EXTERNALSYM LPNETRESOURCE2A}
  694.   PNETRESOURCE2A = ^NETRESOURCE2A;
  695.   {$EXTERNALSYM PNETRESOURCE2A}
  696.   _NETRESOURCE2A = record
  697.     dwScope: DWORD;
  698.     dwType: DWORD;
  699.     dwUsage: DWORD;
  700.     dwDisplayType: DWORD;
  701.     lpLocalName: LPSTR;
  702.     lpRemoteName: LPSTR;
  703.     lpComment: LPSTR;
  704.     ns_info: NS_INFO;
  705.     ServiceType: TGUID;
  706.     dwProtocols: DWORD;
  707.     lpiProtocols: PINT;
  708.   end;
  709.   {$EXTERNALSYM _NETRESOURCE2A}
  710.   NETRESOURCE2A = _NETRESOURCE2A;
  711.   {$EXTERNALSYM NETRESOURCE2A}
  712.   TNetResource2A = NETRESOURCE2A;
  713. //
  714. // NETRESOURCE2 Structure
  715. //
  716.   LPNETRESOURCE2W = ^NETRESOURCE2W;
  717.   {$EXTERNALSYM LPNETRESOURCE2W}
  718.   PNETRESOURCE2W = ^NETRESOURCE2W;
  719.   {$EXTERNALSYM PNETRESOURCE2W}
  720.   _NETRESOURCE2W = record
  721.     dwScope: DWORD;
  722.     dwType: DWORD;
  723.     dwUsage: DWORD;
  724.     dwDisplayType: DWORD;
  725.     lpLocalName: LPWSTR;
  726.     lpRemoteName: LPWSTR;
  727.     lpComment: LPWSTR;
  728.     ns_info: NS_INFO;
  729.     ServiceType: TGUID;
  730.     dwProtocols: DWORD;
  731.     lpiProtocols: PINT;
  732.   end;
  733.   {$EXTERNALSYM _NETRESOURCE2W}
  734.   NETRESOURCE2W = _NETRESOURCE2W;
  735.   {$EXTERNALSYM NETRESOURCE2W}
  736.   TNetResource2W = NETRESOURCE2W;
  737. {$IFDEF UNICODE}
  738.   NETRESOURCE2 = NETRESOURCE2W;
  739.   {$EXTERNALSYM NETRESOURCE2}
  740.   PNETRESOURCE2 = PNETRESOURCE2W;
  741.   {$EXTERNALSYM PNETRESOURCE2}
  742.   LPNETRESOURCE2 = LPNETRESOURCE2W;
  743.   {$EXTERNALSYM LPNETRESOURCE2}
  744.   TNetResource2 = TNetResource2W;
  745. {$ELSE}
  746.   NETRESOURCE2 = NETRESOURCE2A;
  747.   {$EXTERNALSYM NETRESOURCE2}
  748.   PNETRESOURCE2 = PNETRESOURCE2A;
  749.   {$EXTERNALSYM PNETRESOURCE2}
  750.   LPNETRESOURCE2 = LPNETRESOURCE2A;
  751.   {$EXTERNALSYM LPNETRESOURCE2}
  752.   TNetResource2 = TNetResource2A;
  753. {$ENDIF}
  754.   LPFN_NSPAPI = function: DWORD; stdcall;
  755.   {$EXTERNALSYM LPFN_NSPAPI}
  756.   TFnNspApi = LPFN_NSPAPI; 
  757. //
  758. // Structures for using the service routines asynchronously.
  759. //
  760. type
  761.   LPSERVICE_CALLBACK_PROC = procedure (lParam: LPARAM; hAsyncTaskHandle: HANDLE); stdcall;
  762.   {$EXTERNALSYM LPSERVICE_CALLBACK_PROC}
  763.   TServiceCallbackProc = LPSERVICE_CALLBACK_PROC;
  764. type
  765.   LPSERVICE_ASYNC_INFO = ^SERVICE_ASYNC_INFO;
  766.   {$EXTERNALSYM LPSERVICE_ASYNC_INFO}
  767.   PSERVICE_ASYNC_INFO = ^SERVICE_ASYNC_INFO;
  768.   {$EXTERNALSYM PSERVICE_ASYNC_INFO}
  769.   _SERVICE_ASYNC_INFO = record
  770.     lpServiceCallbackProc: LPSERVICE_CALLBACK_PROC;
  771.     lParam: LPARAM;
  772.     hAsyncTaskHandle: HANDLE;
  773.   end;
  774.   {$EXTERNALSYM _SERVICE_ASYNC_INFO}
  775.   SERVICE_ASYNC_INFO = _SERVICE_ASYNC_INFO;
  776.   {$EXTERNALSYM SERVICE_ASYNC_INFO}
  777.   TServiceAsyncInfo = SERVICE_ASYNC_INFO;
  778.   PServiceAsyncInfo = LPSERVICE_ASYNC_INFO;
  779. //
  780. // Public NSP API prototypes.
  781. //
  782. function EnumProtocolsA(lpiProtocols: PINT; lpProtocolBuffer: LPVOID; lpdwBufferLength: LPDWORD): Integer; stdcall;
  783. {$EXTERNALSYM EnumProtocolsA}
  784. function EnumProtocolsW(lpiProtocols: PINT; lpProtocolBuffer: LPVOID; lpdwBufferLength: LPDWORD): Integer; stdcall;
  785. {$EXTERNALSYM EnumProtocolsW}
  786. {$IFDEF UNICODE}
  787. function EnumProtocols(lpiProtocols: PINT; lpProtocolBuffer: LPVOID; lpdwBufferLength: LPDWORD): Integer; stdcall;
  788. {$EXTERNALSYM EnumProtocols}
  789. {$ELSE}
  790. function EnumProtocols(lpiProtocols: PINT; lpProtocolBuffer: LPVOID; lpdwBufferLength: LPDWORD): Integer; stdcall;
  791. {$EXTERNALSYM EnumProtocols}
  792. {$ENDIF}
  793. function GetAddressByNameA(dwNameSpace: DWORD; const lpServiceType: TGUID;
  794.   lpServiceName: LPSTR; lpiProtocols: PINT; dwResolution: DWORD;
  795.   lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO; lpCsaddrBuffer: LPVOID;
  796.   var lpdwBufferLength: DWORD; lpAliasBuffer: LPSTR; lpdwAliasBufferLength: LPDWORD): Integer; stdcall;
  797. {$EXTERNALSYM GetAddressByNameA}
  798. function GetAddressByNameW(dwNameSpace: DWORD; const lpServiceType: TGUID;
  799.   lpServiceName: LPWSTR; lpiProtocols: PINT; dwResolution: DWORD;
  800.   lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO; lpCsaddrBuffer: LPVOID;
  801.   var lpdwBufferLength: DWORD; lpAliasBuffer: LPWSTR; lpdwAliasBufferLength: LPDWORD): Integer; stdcall;
  802. {$EXTERNALSYM GetAddressByNameW}
  803. {$IFDEF UNICODE}
  804. function GetAddressByName(dwNameSpace: DWORD; const lpServiceType: TGUID;
  805.   lpServiceName: LPWSTR; lpiProtocols: PINT; dwResolution: DWORD;
  806.   lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO; lpCsaddrBuffer: LPVOID;
  807.   var lpdwBufferLength: DWORD; lpAliasBuffer: LPWSTR; lpdwAliasBufferLength: LPDWORD): Integer; stdcall;
  808. {$EXTERNALSYM GetAddressByName}
  809. {$ELSE}
  810. function GetAddressByName(dwNameSpace: DWORD; const lpServiceType: TGUID;
  811.   lpServiceName: LPSTR; lpiProtocols: PINT; dwResolution: DWORD;
  812.   lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO; lpCsaddrBuffer: LPVOID;
  813.   var lpdwBufferLength: DWORD; lpAliasBuffer: LPSTR; lpdwAliasBufferLength: LPDWORD): Integer; stdcall;
  814. {$EXTERNALSYM GetAddressByName}
  815. {$ENDIF}
  816. function GetTypeByNameA(lpServiceName: LPSTR; var lpServiceType: TGUID): Integer; stdcall;
  817. {$EXTERNALSYM GetTypeByNameA}
  818. function GetTypeByNameW(lpServiceName: LPWSTR; var lpServiceType: TGUID): Integer; stdcall;
  819. {$EXTERNALSYM GetTypeByNameW}
  820. {$IFDEF UNICODE}
  821. function GetTypeByName(lpServiceName: LPWSTR; var lpServiceType: TGUID): Integer; stdcall;
  822. {$EXTERNALSYM GetTypeByName}
  823. {$ELSE}
  824. function GetTypeByName(lpServiceName: LPSTR; var lpServiceType: TGUID): Integer; stdcall;
  825. {$EXTERNALSYM GetTypeByName}
  826. {$ENDIF}
  827. function GetNameByTypeA(const lpServiceType: TGUID; lpServiceName: LPSTR; dwNameLength: DWORD): Integer; stdcall;
  828. {$EXTERNALSYM GetNameByTypeA}
  829. function GetNameByTypeW(const lpServiceType: TGUID; lpServiceName: LPWSTR; dwNameLength: DWORD): Integer; stdcall;
  830. {$EXTERNALSYM GetNameByTypeW}
  831. {$IFDEF UNICODE}
  832. function GetNameByType(const lpServiceType: TGUID; lpServiceName: LPWSTR; dwNameLength: DWORD): Integer; stdcall;
  833. {$EXTERNALSYM GetNameByType}
  834. {$ELSE}
  835. function GetNameByType(const lpServiceType: TGUID; lpServiceName: LPSTR; dwNameLength: DWORD): Integer; stdcall;
  836. {$EXTERNALSYM GetNameByType}
  837. {$ENDIF}
  838. function SetServiceA(dwNameSpace, dwOperation, dwFlags: DWORD;
  839.   const lpServiceInfo: SERVICE_INFOA; lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO;
  840.   var lpdwStatusFlags: DWORD): Integer; stdcall;
  841. {$EXTERNALSYM SetServiceA}
  842. function SetServiceW(dwNameSpace, dwOperation, dwFlags: DWORD;
  843.   const lpServiceInfo: SERVICE_INFOW; lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO;
  844.   var lpdwStatusFlags: DWORD): Integer; stdcall;
  845. {$EXTERNALSYM SetServiceW}
  846. {$IFDEF UNICODE}
  847. function SetService(dwNameSpace, dwOperation, dwFlags: DWORD;
  848.   const lpServiceInfo: SERVICE_INFOW; lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO;
  849.   var lpdwStatusFlags: DWORD): Integer; stdcall;
  850. {$EXTERNALSYM SetService}
  851. {$ELSE}
  852. function SetService(dwNameSpace, dwOperation, dwFlags: DWORD;
  853.   const lpServiceInfo: SERVICE_INFOA; lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO;
  854.   var lpdwStatusFlags: DWORD): Integer; stdcall;
  855. {$EXTERNALSYM SetService}
  856. {$ENDIF}
  857. function GetServiceA(dwNameSpace: DWORD; const lpGuid: TGUID; lpServiceName: LPSTR;
  858.   dwProperties: DWORD; lpBuffer: LPVOID; var lpdwBufferSize: DWORD;
  859.   lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO): Integer; stdcall;
  860. {$EXTERNALSYM GetServiceA}
  861. function GetServiceW(dwNameSpace: DWORD; const lpGuid: TGUID; lpServiceName: LPWSTR;
  862.   dwProperties: DWORD; lpBuffer: LPVOID; var lpdwBufferSize: DWORD;
  863.   lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO): Integer; stdcall;
  864. {$EXTERNALSYM GetServiceW}
  865. {$IFDEF UNICODE}
  866. function GetService(dwNameSpace: DWORD; const lpGuid: TGUID; lpServiceName: LPWSTR;
  867.   dwProperties: DWORD; lpBuffer: LPVOID; var lpdwBufferSize: DWORD;
  868.   lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO): Integer; stdcall;
  869. {$EXTERNALSYM GetService}
  870. {$ELSE}
  871. function GetService(dwNameSpace: DWORD; const lpGuid: TGUID; lpServiceName: LPSTR;
  872.   dwProperties: DWORD; lpBuffer: LPVOID; var lpdwBufferSize: DWORD;
  873.   lpServiceAsyncInfo: LPSERVICE_ASYNC_INFO): Integer; stdcall;
  874. {$EXTERNALSYM GetService}
  875. {$ENDIF}
  876. implementation
  877. const
  878.   nsplib = 'wsock32.dll';
  879. {$IFDEF DYNAMIC_LINK}
  880. var
  881.   _EnumProtocolsA: Pointer;
  882. function EnumProtocolsA;
  883. begin
  884.   GetProcedureAddress(_EnumProtocolsA, nsplib, 'EnumProtocolsA');
  885.   asm
  886.     mov esp, ebp
  887.     pop ebp
  888.     jmp [_EnumProtocolsA]
  889.   end;
  890. end;
  891. {$ELSE}
  892. function EnumProtocolsA; external nsplib name 'EnumProtocolsA';
  893. {$ENDIF DYNAMIC_LINK}
  894. {$IFDEF DYNAMIC_LINK}
  895. var
  896.   _EnumProtocolsW: Pointer;
  897. function EnumProtocolsW;
  898. begin
  899.   GetProcedureAddress(_EnumProtocolsW, nsplib, 'EnumProtocolsW');
  900.   asm
  901.     mov esp, ebp
  902.     pop ebp
  903.     jmp [_EnumProtocolsW]
  904.   end;
  905. end;
  906. {$ELSE}
  907. function EnumProtocolsW; external nsplib name 'EnumProtocolsW';
  908. {$ENDIF DYNAMIC_LINK}
  909. {$IFDEF UNICODE}
  910. {$IFDEF DYNAMIC_LINK}
  911. var
  912.   _EnumProtocols: Pointer;
  913. function EnumProtocols;
  914. begin
  915.   GetProcedureAddress(_EnumProtocols, nsplib, 'EnumProtocolsW');
  916.   asm
  917.     mov esp, ebp
  918.     pop ebp
  919.     jmp [_EnumProtocols]
  920.   end;
  921. end;
  922. {$ELSE}
  923. function EnumProtocols; external nsplib name 'EnumProtocolsW';
  924. {$ENDIF DYNAMIC_LINK}
  925. {$ELSE}
  926. {$IFDEF DYNAMIC_LINK}
  927. var
  928.   _EnumProtocols: Pointer;
  929. function EnumProtocols;
  930. begin
  931.   GetProcedureAddress(_EnumProtocols, nsplib, 'EnumProtocolsA');
  932.   asm
  933.     mov esp, ebp
  934.     pop ebp
  935.     jmp [_EnumProtocols]
  936.   end;
  937. end;
  938. {$ELSE}
  939. function EnumProtocols; external nsplib name 'EnumProtocolsA';
  940. {$ENDIF DYNAMIC_LINK}
  941. {$ENDIF}
  942. {$IFDEF DYNAMIC_LINK}
  943. var
  944.   _GetAddressByNameA: Pointer;
  945. function GetAddressByNameA;
  946. begin
  947.   GetProcedureAddress(_GetAddressByNameA, nsplib, 'GetAddressByNameA');
  948.   asm
  949.     mov esp, ebp
  950.     pop ebp
  951.     jmp [_GetAddressByNameA]
  952.   end;
  953. end;
  954. {$ELSE}
  955. function GetAddressByNameA; external nsplib name 'GetAddressByNameA';
  956. {$ENDIF DYNAMIC_LINK}
  957. {$IFDEF DYNAMIC_LINK}
  958. var
  959.   _GetAddressByNameW: Pointer;
  960. function GetAddressByNameW;
  961. begin
  962.   GetProcedureAddress(_GetAddressByNameW, nsplib, 'GetAddressByNameW');
  963.   asm
  964.     mov esp, ebp
  965.     pop ebp
  966.     jmp [_GetAddressByNameW]
  967.   end;
  968. end;
  969. {$ELSE}
  970. function GetAddressByNameW; external nsplib name 'GetAddressByNameW';
  971. {$ENDIF DYNAMIC_LINK}
  972. {$IFDEF UNICODE}
  973. {$IFDEF DYNAMIC_LINK}
  974. var
  975.   _GetAddressByName: Pointer;
  976. function GetAddressByName;
  977. begin
  978.   GetProcedureAddress(_GetAddressByName, nsplib, 'GetAddressByNameW');
  979.   asm
  980.     mov esp, ebp
  981.     pop ebp
  982.     jmp [_GetAddressByName]
  983.   end;
  984. end;
  985. {$ELSE}
  986. function GetAddressByName; external nsplib name 'GetAddressByNameW';
  987. {$ENDIF DYNAMIC_LINK}
  988. {$ELSE}
  989. {$IFDEF DYNAMIC_LINK}
  990. var
  991.   _GetAddressByName: Pointer;
  992. function GetAddressByName;
  993. begin
  994.   GetProcedureAddress(_GetAddressByName, nsplib, 'GetAddressByNameA');
  995.   asm
  996.     mov esp, ebp
  997.     pop ebp
  998.     jmp [_GetAddressByName]
  999.   end;
  1000. end;
  1001. {$ELSE}
  1002. function GetAddressByName; external nsplib name 'GetAddressByNameA';
  1003. {$ENDIF DYNAMIC_LINK}
  1004. {$ENDIF}
  1005. {$IFDEF DYNAMIC_LINK}
  1006. var
  1007.   _GetTypeByNameA: Pointer;
  1008. function GetTypeByNameA;
  1009. begin
  1010.   GetProcedureAddress(_GetTypeByNameA, nsplib, 'GetTypeByNameA');
  1011.   asm
  1012.     mov esp, ebp
  1013.     pop ebp
  1014.     jmp [_GetTypeByNameA]
  1015.   end;
  1016. end;
  1017. {$ELSE}
  1018. function GetTypeByNameA; external nsplib name 'GetTypeByNameA';
  1019. {$ENDIF DYNAMIC_LINK}
  1020. {$IFDEF DYNAMIC_LINK}
  1021. var
  1022.   _GetTypeByNameW: Pointer;
  1023. function GetTypeByNameW;
  1024. begin
  1025.   GetProcedureAddress(_GetTypeByNameW, nsplib, 'GetTypeByNameW');
  1026.   asm
  1027.     mov esp, ebp
  1028.     pop ebp
  1029.     jmp [_GetTypeByNameW]
  1030.   end;
  1031. end;
  1032. {$ELSE}
  1033. function GetTypeByNameW; external nsplib name 'GetTypeByNameW';
  1034. {$ENDIF DYNAMIC_LINK}
  1035. {$IFDEF UNICODE}
  1036. {$IFDEF DYNAMIC_LINK}
  1037. var
  1038.   _GetTypeByName: Pointer;
  1039. function GetTypeByName;
  1040. begin
  1041.   GetProcedureAddress(_GetTypeByName, nsplib, 'GetTypeByNameW');
  1042.   asm
  1043.     mov esp, ebp
  1044.     pop ebp
  1045.     jmp [_GetTypeByName]
  1046.   end;
  1047. end;
  1048. {$ELSE}
  1049. function GetTypeByName; external nsplib name 'GetTypeByNameW';
  1050. {$ENDIF DYNAMIC_LINK}
  1051. {$ELSE}
  1052. {$IFDEF DYNAMIC_LINK}
  1053. var
  1054.   _GetTypeByName: Pointer;
  1055. function GetTypeByName;
  1056. begin
  1057.   GetProcedureAddress(_GetTypeByName, nsplib, 'GetTypeByNameA');
  1058.   asm
  1059.     mov esp, ebp
  1060.     pop ebp
  1061.     jmp [_GetTypeByName]
  1062.   end;
  1063. end;
  1064. {$ELSE}
  1065. function GetTypeByName; external nsplib name 'GetTypeByNameA';
  1066. {$ENDIF DYNAMIC_LINK}
  1067. {$ENDIF}
  1068. {$IFDEF DYNAMIC_LINK}
  1069. var
  1070.   _GetNameByTypeA: Pointer;
  1071. function GetNameByTypeA;
  1072. begin
  1073.   GetProcedureAddress(_GetNameByTypeA, nsplib, 'GetNameByTypeA');
  1074.   asm
  1075.     mov esp, ebp
  1076.     pop ebp
  1077.     jmp [_GetNameByTypeA]
  1078.   end;
  1079. end;
  1080. {$ELSE}
  1081. function GetNameByTypeA; external nsplib name 'GetNameByTypeA';
  1082. {$ENDIF DYNAMIC_LINK}
  1083. {$IFDEF DYNAMIC_LINK}
  1084. var
  1085.   _GetNameByTypeW: Pointer;
  1086. function GetNameByTypeW;
  1087. begin
  1088.   GetProcedureAddress(_GetNameByTypeW, nsplib, 'GetNameByTypeW');
  1089.   asm
  1090.     mov esp, ebp
  1091.     pop ebp
  1092.     jmp [_GetNameByTypeW]
  1093.   end;
  1094. end;
  1095. {$ELSE}
  1096. function GetNameByTypeW; external nsplib name 'GetNameByTypeW';
  1097. {$ENDIF DYNAMIC_LINK}
  1098. {$IFDEF UNICODE}
  1099. {$IFDEF DYNAMIC_LINK}
  1100. var
  1101.   _GetNameByType: Pointer;
  1102. function GetNameByType;
  1103. begin
  1104.   GetProcedureAddress(_GetNameByType, nsplib, 'GetNameByTypeW');
  1105.   asm
  1106.     mov esp, ebp
  1107.     pop ebp
  1108.     jmp [_GetNameByType]
  1109.   end;
  1110. end;
  1111. {$ELSE}
  1112. function GetNameByType; external nsplib name 'GetNameByTypeW';
  1113. {$ENDIF DYNAMIC_LINK}
  1114. {$ELSE}
  1115. {$IFDEF DYNAMIC_LINK}
  1116. var
  1117.   _GetNameByType: Pointer;
  1118. function GetNameByType;
  1119. begin
  1120.   GetProcedureAddress(_GetNameByType, nsplib, 'GetNameByTypeA');
  1121.   asm
  1122.     mov esp, ebp
  1123.     pop ebp
  1124.     jmp [_GetNameByType]
  1125.   end;
  1126. end;
  1127. {$ELSE}
  1128. function GetNameByType; external nsplib name 'GetNameByTypeA';
  1129. {$ENDIF DYNAMIC_LINK}
  1130. {$ENDIF}
  1131. {$IFDEF DYNAMIC_LINK}
  1132. var
  1133.   _SetServiceA: Pointer;
  1134. function SetServiceA;
  1135. begin
  1136.   GetProcedureAddress(_SetServiceA, nsplib, 'SetServiceA');
  1137.   asm
  1138.     mov esp, ebp
  1139.     pop ebp
  1140.     jmp [_SetServiceA]
  1141.   end;
  1142. end;
  1143. {$ELSE}
  1144. function SetServiceA; external nsplib name 'SetServiceA';
  1145. {$ENDIF DYNAMIC_LINK}
  1146. {$IFDEF DYNAMIC_LINK}
  1147. var
  1148.   _SetServiceW: Pointer;
  1149. function SetServiceW;
  1150. begin
  1151.   GetProcedureAddress(_SetServiceW, nsplib, 'SetServiceW');
  1152.   asm
  1153.     mov esp, ebp
  1154.     pop ebp
  1155.     jmp [_SetServiceW]
  1156.   end;
  1157. end;
  1158. {$ELSE}
  1159. function SetServiceW; external nsplib name 'SetServiceW';
  1160. {$ENDIF DYNAMIC_LINK}
  1161. {$IFDEF UNICODE}
  1162. {$IFDEF DYNAMIC_LINK}
  1163. var
  1164.   _SetService: Pointer;
  1165. function SetService;
  1166. begin
  1167.   GetProcedureAddress(_SetService, nsplib, 'SetServiceW');
  1168.   asm
  1169.     mov esp, ebp
  1170.     pop ebp
  1171.     jmp [_SetService]
  1172.   end;
  1173. end;
  1174. {$ELSE}
  1175. function SetService; external nsplib name 'SetServiceW';
  1176. {$ENDIF DYNAMIC_LINK}
  1177. {$ELSE}
  1178. {$IFDEF DYNAMIC_LINK}
  1179. var
  1180.   _SetService: Pointer;
  1181. function SetService;
  1182. begin
  1183.   GetProcedureAddress(_SetService, nsplib, 'SetServiceA');
  1184.   asm
  1185.     mov esp, ebp
  1186.     pop ebp
  1187.     jmp [_SetService]
  1188.   end;
  1189. end;
  1190. {$ELSE}
  1191. function SetService; external nsplib name 'SetServiceA';
  1192. {$ENDIF DYNAMIC_LINK}
  1193. {$ENDIF}
  1194. {$IFDEF DYNAMIC_LINK}
  1195. var
  1196.   _GetServiceA: Pointer;
  1197. function GetServiceA;
  1198. begin
  1199.   GetProcedureAddress(_GetServiceA, nsplib, 'GetServiceA');
  1200.   asm
  1201.     mov esp, ebp
  1202.     pop ebp
  1203.     jmp [_GetServiceA]
  1204.   end;
  1205. end;
  1206. {$ELSE}
  1207. function GetServiceA; external nsplib name 'GetServiceA';
  1208. {$ENDIF DYNAMIC_LINK}
  1209. {$IFDEF DYNAMIC_LINK}
  1210. var
  1211.   _GetServiceW: Pointer;
  1212. function GetServiceW;
  1213. begin
  1214.   GetProcedureAddress(_GetServiceW, nsplib, 'GetServiceW');
  1215.   asm
  1216.     mov esp, ebp
  1217.     pop ebp
  1218.     jmp [_GetServiceW]
  1219.   end;
  1220. end;
  1221. {$ELSE}
  1222. function GetServiceW; external nsplib name 'GetServiceW';
  1223. {$ENDIF DYNAMIC_LINK}
  1224. {$IFDEF UNICODE}
  1225. {$IFDEF DYNAMIC_LINK}
  1226. var
  1227.   _GetService: Pointer;
  1228. function GetService;
  1229. begin
  1230.   GetProcedureAddress(_GetService, nsplib, 'GetServiceW');
  1231.   asm
  1232.     mov esp, ebp
  1233.     pop ebp
  1234.     jmp [_GetService]
  1235.   end;
  1236. end;
  1237. {$ELSE}
  1238. function GetService; external nsplib name 'GetServiceW';
  1239. {$ENDIF DYNAMIC_LINK}
  1240. {$ELSE}
  1241. {$IFDEF DYNAMIC_LINK}
  1242. var
  1243.   _GetService: Pointer;
  1244. function GetService;
  1245. begin
  1246.   GetProcedureAddress(_GetService, nsplib, 'GetServiceA');
  1247.   asm
  1248.     mov esp, ebp
  1249.     pop ebp
  1250.     jmp [_GetService]
  1251.   end;
  1252. end;
  1253. {$ELSE}
  1254. function GetService; external nsplib name 'GetServiceA';
  1255. {$ENDIF DYNAMIC_LINK}
  1256. {$ENDIF}
  1257. end.