jwalmuse.pas 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. {******************************************************************************}
  2. { }
  3. { Lan Manager Use 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: lmuse.h, released November 2001. The original Pascal }
  9. { code is: LmUse.pas, released Februari 2002. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott 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 }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaLmUse;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "lmuse.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaLmCons, JwaWinType;
  51. //
  52. // Function Prototypes
  53. //
  54. function NetUseAdd(UncServerName: LMSTR; Level: DWORD; Buf: LPBYTE; ParmError: LPDWORD): NET_API_STATUS; stdcall;
  55. {$EXTERNALSYM NetUseAdd}
  56. function NetUseDel(UncServerName: LMSTR; UseName: LMSTR; ForceCond: DWORD): NET_API_STATUS; stdcall;
  57. {$EXTERNALSYM NetUseDel}
  58. function NetUseEnum(UncServerName: LMSTR; Level: DWORD; var BufPtr: LPBYTE; PreferedMaximumSize: DWORD; EntriesRead: LPDWORD; TotalEntries: LPDWORD; ResumeHandle: LPDWORD): NET_API_STATUS; stdcall;
  59. {$EXTERNALSYM NetUseEnum}
  60. function NetUseGetInfo(UncServerName: LMSTR; UseName: LMSTR; Level: DWORD; var BufPtr: LPBYTE): NET_API_STATUS; stdcall;
  61. {$EXTERNALSYM NetUseGetInfo}
  62. //
  63. // Data Structures
  64. //
  65. type
  66. _USE_INFO_0 = record
  67. ui0_local: LMSTR;
  68. ui0_remote: LMSTR;
  69. end;
  70. {$EXTERNALSYM _USE_INFO_0}
  71. USE_INFO_0 = _USE_INFO_0;
  72. {$EXTERNALSYM USE_INFO_0}
  73. PUSE_INFO_0 = ^USE_INFO_0;
  74. {$EXTERNALSYM PUSE_INFO_0}
  75. LPUSE_INFO_0 = ^USE_INFO_0;
  76. {$EXTERNALSYM LPUSE_INFO_0}
  77. TUseInfo0 = USE_INFO_0;
  78. PUseInfo0 = PUSE_INFO_0;
  79. _USE_INFO_1 = record
  80. ui1_local: LMSTR;
  81. ui1_remote: LMSTR;
  82. ui1_password: LMSTR;
  83. ui1_status: DWORD;
  84. ui1_asg_type: DWORD;
  85. ui1_refcount: DWORD;
  86. ui1_usecount: DWORD;
  87. end;
  88. {$EXTERNALSYM _USE_INFO_1}
  89. USE_INFO_1 = _USE_INFO_1;
  90. {$EXTERNALSYM USE_INFO_1}
  91. PUSE_INFO_1 = ^USE_INFO_1;
  92. {$EXTERNALSYM PUSE_INFO_1}
  93. LPUSE_INFO_1 = ^USE_INFO_1;
  94. {$EXTERNALSYM LPUSE_INFO_1}
  95. TUseInfo1 = USE_INFO_1;
  96. PUseInfo1 = PUSE_INFO_1;
  97. _USE_INFO_2 = record
  98. ui2_local: LMSTR;
  99. ui2_remote: LMSTR;
  100. ui2_password: LMSTR;
  101. ui2_status: DWORD;
  102. ui2_asg_type: DWORD;
  103. ui2_refcount: DWORD;
  104. ui2_usecount: DWORD;
  105. ui2_username: LMSTR;
  106. ui2_domainname: LMSTR;
  107. end;
  108. {$EXTERNALSYM _USE_INFO_2}
  109. USE_INFO_2 = _USE_INFO_2;
  110. {$EXTERNALSYM USE_INFO_2}
  111. PUSE_INFO_2 = ^USE_INFO_2;
  112. {$EXTERNALSYM PUSE_INFO_2}
  113. LPUSE_INFO_2 = ^USE_INFO_2;
  114. {$EXTERNALSYM LPUSE_INFO_2}
  115. TUseInfo2 = USE_INFO_2;
  116. PUseInfo2 = PUSE_INFO_2;
  117. _USE_INFO_3 = record
  118. ui3_ui2: USE_INFO_2;
  119. ui3_flags: ULONG;
  120. end;
  121. {$EXTERNALSYM _USE_INFO_3}
  122. USE_INFO_3 = _USE_INFO_3;
  123. {$EXTERNALSYM USE_INFO_3}
  124. PUSE_INFO_3 = ^USE_INFO_3;
  125. {$EXTERNALSYM PUSE_INFO_3}
  126. LPUSE_INFO_3 = ^USE_INFO_3;
  127. {$EXTERNALSYM LPUSE_INFO_3}
  128. TUseInfo3 = USE_INFO_3;
  129. PUseInfo3 = PUSE_INFO_3;
  130. //
  131. // Special Values and Constants
  132. //
  133. //
  134. // One of these values indicates the parameter within an information
  135. // structure that is invalid when ERROR_INVALID_PARAMETER is returned by
  136. // NetUseAdd.
  137. //
  138. const
  139. USE_LOCAL_PARMNUM = 1;
  140. {$EXTERNALSYM USE_LOCAL_PARMNUM}
  141. USE_REMOTE_PARMNUM = 2;
  142. {$EXTERNALSYM USE_REMOTE_PARMNUM}
  143. USE_PASSWORD_PARMNUM = 3;
  144. {$EXTERNALSYM USE_PASSWORD_PARMNUM}
  145. USE_ASGTYPE_PARMNUM = 4;
  146. {$EXTERNALSYM USE_ASGTYPE_PARMNUM}
  147. USE_USERNAME_PARMNUM = 5;
  148. {$EXTERNALSYM USE_USERNAME_PARMNUM}
  149. USE_DOMAINNAME_PARMNUM = 6;
  150. {$EXTERNALSYM USE_DOMAINNAME_PARMNUM}
  151. //
  152. // Values appearing in the ui1_status field of use_info_1 structure.
  153. // Note that USE_SESSLOST and USE_DISCONN are synonyms.
  154. //
  155. USE_OK = 0;
  156. {$EXTERNALSYM USE_OK}
  157. USE_PAUSED = 1;
  158. {$EXTERNALSYM USE_PAUSED}
  159. USE_SESSLOST = 2;
  160. {$EXTERNALSYM USE_SESSLOST}
  161. USE_DISCONN = 2;
  162. {$EXTERNALSYM USE_DISCONN}
  163. USE_NETERR = 3;
  164. {$EXTERNALSYM USE_NETERR}
  165. USE_CONN = 4;
  166. {$EXTERNALSYM USE_CONN}
  167. USE_RECONN = 5;
  168. {$EXTERNALSYM USE_RECONN}
  169. //
  170. // Values of the ui1_asg_type field of use_info_1 structure
  171. //
  172. USE_WILDCARD = DWORD(-1);
  173. {$EXTERNALSYM USE_WILDCARD}
  174. USE_DISKDEV = 0;
  175. {$EXTERNALSYM USE_DISKDEV}
  176. USE_SPOOLDEV = 1;
  177. {$EXTERNALSYM USE_SPOOLDEV}
  178. USE_CHARDEV = 2;
  179. {$EXTERNALSYM USE_CHARDEV}
  180. USE_IPC = 3;
  181. {$EXTERNALSYM USE_IPC}
  182. //
  183. // Flags defined in the use_info_3 structure
  184. //
  185. CREATE_NO_CONNECT = $1; // creation flags
  186. {$EXTERNALSYM CREATE_NO_CONNECT}
  187. CREATE_BYPASS_CSC = $2; // force connection to server, bypassing CSC
  188. {$EXTERNALSYM CREATE_BYPASS_CSC}
  189. // all ops on this connection go to the server,
  190. // never to the cache
  191. USE_DEFAULT_CREDENTIALS = $4; // No explicit credentials passed to NetUseAdd
  192. {$EXTERNALSYM USE_DEFAULT_CREDENTIALS}
  193. implementation
  194. {$IFDEF DYNAMIC_LINK}
  195. var
  196. _NetUseAdd: Pointer;
  197. function NetUseAdd;
  198. begin
  199. GetProcedureAddress(_NetUseAdd, netapi32, 'NetUseAdd');
  200. asm
  201. MOV ESP, EBP
  202. POP EBP
  203. JMP [_NetUseAdd]
  204. end;
  205. end;
  206. var
  207. _NetUseDel: Pointer;
  208. function NetUseDel;
  209. begin
  210. GetProcedureAddress(_NetUseDel, netapi32, 'NetUseDel');
  211. asm
  212. MOV ESP, EBP
  213. POP EBP
  214. JMP [_NetUseDel]
  215. end;
  216. end;
  217. var
  218. _NetUseEnum: Pointer;
  219. function NetUseEnum;
  220. begin
  221. GetProcedureAddress(_NetUseEnum, netapi32, 'NetUseEnum');
  222. asm
  223. MOV ESP, EBP
  224. POP EBP
  225. JMP [_NetUseEnum]
  226. end;
  227. end;
  228. var
  229. _NetUseGetInfo: Pointer;
  230. function NetUseGetInfo;
  231. begin
  232. GetProcedureAddress(_NetUseGetInfo, netapi32, 'NetUseGetInfo');
  233. asm
  234. MOV ESP, EBP
  235. POP EBP
  236. JMP [_NetUseGetInfo]
  237. end;
  238. end;
  239. {$ELSE}
  240. function NetUseAdd; external netapi32 name 'NetUseAdd';
  241. function NetUseDel; external netapi32 name 'NetUseDel';
  242. function NetUseEnum; external netapi32 name 'NetUseEnum';
  243. function NetUseGetInfo; external netapi32 name 'NetUseGetInfo';
  244. {$ENDIF DYNAMIC_LINK}
  245. end.