jwalmuse.pas 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. // $Id: JwaLmUse.pas,v 1.9 2005/09/07 09:54:54 marquardt Exp $
  43. {$IFNDEF JWA_INCLUDEMODE}
  44. unit JwaLmUse;
  45. {$WEAKPACKAGEUNIT}
  46. {$I jediapilib.inc}
  47. interface
  48. uses
  49. JwaWindows, JwaLmCons;
  50. {$ENDIF !JWA_INCLUDEMODE}
  51. {$IFDEF JWA_INTERFACESECTION}
  52. {$HPPEMIT ''}
  53. {$HPPEMIT '#include "lmuse.h"'}
  54. {$HPPEMIT ''}
  55. //
  56. // Function Prototypes
  57. //
  58. function NetUseAdd(UncServerName: LMSTR; Level: DWORD; Buf: LPBYTE; ParmError: LPDWORD): NET_API_STATUS; stdcall;
  59. {$EXTERNALSYM NetUseAdd}
  60. function NetUseDel(UncServerName: LMSTR; UseName: LMSTR; ForceCond: DWORD): NET_API_STATUS; stdcall;
  61. {$EXTERNALSYM NetUseDel}
  62. function NetUseEnum(UncServerName: LMSTR; Level: DWORD; var BufPtr: LPBYTE; PreferedMaximumSize: DWORD; EntriesRead: LPDWORD; TotalEntries: LPDWORD; ResumeHandle: LPDWORD): NET_API_STATUS; stdcall;
  63. {$EXTERNALSYM NetUseEnum}
  64. function NetUseGetInfo(UncServerName: LMSTR; UseName: LMSTR; Level: DWORD; var BufPtr: LPBYTE): NET_API_STATUS; stdcall;
  65. {$EXTERNALSYM NetUseGetInfo}
  66. //
  67. // Data Structures
  68. //
  69. type
  70. _USE_INFO_0 = record
  71. ui0_local: LMSTR;
  72. ui0_remote: LMSTR;
  73. end;
  74. {$EXTERNALSYM _USE_INFO_0}
  75. USE_INFO_0 = _USE_INFO_0;
  76. {$EXTERNALSYM USE_INFO_0}
  77. PUSE_INFO_0 = ^USE_INFO_0;
  78. {$EXTERNALSYM PUSE_INFO_0}
  79. LPUSE_INFO_0 = ^USE_INFO_0;
  80. {$EXTERNALSYM LPUSE_INFO_0}
  81. TUseInfo0 = USE_INFO_0;
  82. PUseInfo0 = PUSE_INFO_0;
  83. _USE_INFO_1 = record
  84. ui1_local: LMSTR;
  85. ui1_remote: LMSTR;
  86. ui1_password: LMSTR;
  87. ui1_status: DWORD;
  88. ui1_asg_type: DWORD;
  89. ui1_refcount: DWORD;
  90. ui1_usecount: DWORD;
  91. end;
  92. {$EXTERNALSYM _USE_INFO_1}
  93. USE_INFO_1 = _USE_INFO_1;
  94. {$EXTERNALSYM USE_INFO_1}
  95. PUSE_INFO_1 = ^USE_INFO_1;
  96. {$EXTERNALSYM PUSE_INFO_1}
  97. LPUSE_INFO_1 = ^USE_INFO_1;
  98. {$EXTERNALSYM LPUSE_INFO_1}
  99. TUseInfo1 = USE_INFO_1;
  100. PUseInfo1 = PUSE_INFO_1;
  101. _USE_INFO_2 = record
  102. ui2_local: LMSTR;
  103. ui2_remote: LMSTR;
  104. ui2_password: LMSTR;
  105. ui2_status: DWORD;
  106. ui2_asg_type: DWORD;
  107. ui2_refcount: DWORD;
  108. ui2_usecount: DWORD;
  109. ui2_username: LMSTR;
  110. ui2_domainname: LMSTR;
  111. end;
  112. {$EXTERNALSYM _USE_INFO_2}
  113. USE_INFO_2 = _USE_INFO_2;
  114. {$EXTERNALSYM USE_INFO_2}
  115. PUSE_INFO_2 = ^USE_INFO_2;
  116. {$EXTERNALSYM PUSE_INFO_2}
  117. LPUSE_INFO_2 = ^USE_INFO_2;
  118. {$EXTERNALSYM LPUSE_INFO_2}
  119. TUseInfo2 = USE_INFO_2;
  120. PUseInfo2 = PUSE_INFO_2;
  121. _USE_INFO_3 = record
  122. ui3_ui2: USE_INFO_2;
  123. ui3_flags: ULONG;
  124. end;
  125. {$EXTERNALSYM _USE_INFO_3}
  126. USE_INFO_3 = _USE_INFO_3;
  127. {$EXTERNALSYM USE_INFO_3}
  128. PUSE_INFO_3 = ^USE_INFO_3;
  129. {$EXTERNALSYM PUSE_INFO_3}
  130. LPUSE_INFO_3 = ^USE_INFO_3;
  131. {$EXTERNALSYM LPUSE_INFO_3}
  132. TUseInfo3 = USE_INFO_3;
  133. PUseInfo3 = PUSE_INFO_3;
  134. //
  135. // Special Values and Constants
  136. //
  137. //
  138. // One of these values indicates the parameter within an information
  139. // structure that is invalid when ERROR_INVALID_PARAMETER is returned by
  140. // NetUseAdd.
  141. //
  142. const
  143. USE_LOCAL_PARMNUM = 1;
  144. {$EXTERNALSYM USE_LOCAL_PARMNUM}
  145. USE_REMOTE_PARMNUM = 2;
  146. {$EXTERNALSYM USE_REMOTE_PARMNUM}
  147. USE_PASSWORD_PARMNUM = 3;
  148. {$EXTERNALSYM USE_PASSWORD_PARMNUM}
  149. USE_ASGTYPE_PARMNUM = 4;
  150. {$EXTERNALSYM USE_ASGTYPE_PARMNUM}
  151. USE_USERNAME_PARMNUM = 5;
  152. {$EXTERNALSYM USE_USERNAME_PARMNUM}
  153. USE_DOMAINNAME_PARMNUM = 6;
  154. {$EXTERNALSYM USE_DOMAINNAME_PARMNUM}
  155. //
  156. // Values appearing in the ui1_status field of use_info_1 structure.
  157. // Note that USE_SESSLOST and USE_DISCONN are synonyms.
  158. //
  159. USE_OK = 0;
  160. {$EXTERNALSYM USE_OK}
  161. USE_PAUSED = 1;
  162. {$EXTERNALSYM USE_PAUSED}
  163. USE_SESSLOST = 2;
  164. {$EXTERNALSYM USE_SESSLOST}
  165. USE_DISCONN = 2;
  166. {$EXTERNALSYM USE_DISCONN}
  167. USE_NETERR = 3;
  168. {$EXTERNALSYM USE_NETERR}
  169. USE_CONN = 4;
  170. {$EXTERNALSYM USE_CONN}
  171. USE_RECONN = 5;
  172. {$EXTERNALSYM USE_RECONN}
  173. //
  174. // Values of the ui1_asg_type field of use_info_1 structure
  175. //
  176. USE_WILDCARD = DWORD(-1);
  177. {$EXTERNALSYM USE_WILDCARD}
  178. USE_DISKDEV = 0;
  179. {$EXTERNALSYM USE_DISKDEV}
  180. USE_SPOOLDEV = 1;
  181. {$EXTERNALSYM USE_SPOOLDEV}
  182. USE_CHARDEV = 2;
  183. {$EXTERNALSYM USE_CHARDEV}
  184. USE_IPC = 3;
  185. {$EXTERNALSYM USE_IPC}
  186. //
  187. // Flags defined in the use_info_3 structure
  188. //
  189. CREATE_NO_CONNECT = $1; // creation flags
  190. {$EXTERNALSYM CREATE_NO_CONNECT}
  191. CREATE_BYPASS_CSC = $2; // force connection to server, bypassing CSC
  192. {$EXTERNALSYM CREATE_BYPASS_CSC}
  193. // all ops on this connection go to the server,
  194. // never to the cache
  195. USE_DEFAULT_CREDENTIALS = $4; // No explicit credentials passed to NetUseAdd
  196. {$EXTERNALSYM USE_DEFAULT_CREDENTIALS}
  197. {$ENDIF JWA_INTERFACESECTION}
  198. {$IFNDEF JWA_INCLUDEMODE}
  199. implementation
  200. uses
  201. JwaWinDLLNames;
  202. {$ENDIF !JWA_INCLUDEMODE}
  203. {$IFDEF JWA_IMPLEMENTATIONSECTION}
  204. {$IFDEF DYNAMIC_LINK}
  205. var
  206. _NetUseAdd: Pointer;
  207. function NetUseAdd;
  208. begin
  209. GetProcedureAddress(_NetUseAdd, netapi32, 'NetUseAdd');
  210. asm
  211. MOV ESP, EBP
  212. POP EBP
  213. JMP [_NetUseAdd]
  214. end;
  215. end;
  216. var
  217. _NetUseDel: Pointer;
  218. function NetUseDel;
  219. begin
  220. GetProcedureAddress(_NetUseDel, netapi32, 'NetUseDel');
  221. asm
  222. MOV ESP, EBP
  223. POP EBP
  224. JMP [_NetUseDel]
  225. end;
  226. end;
  227. var
  228. _NetUseEnum: Pointer;
  229. function NetUseEnum;
  230. begin
  231. GetProcedureAddress(_NetUseEnum, netapi32, 'NetUseEnum');
  232. asm
  233. MOV ESP, EBP
  234. POP EBP
  235. JMP [_NetUseEnum]
  236. end;
  237. end;
  238. var
  239. _NetUseGetInfo: Pointer;
  240. function NetUseGetInfo;
  241. begin
  242. GetProcedureAddress(_NetUseGetInfo, netapi32, 'NetUseGetInfo');
  243. asm
  244. MOV ESP, EBP
  245. POP EBP
  246. JMP [_NetUseGetInfo]
  247. end;
  248. end;
  249. {$ELSE}
  250. function NetUseAdd; external netapi32 name 'NetUseAdd';
  251. function NetUseDel; external netapi32 name 'NetUseDel';
  252. function NetUseEnum; external netapi32 name 'NetUseEnum';
  253. function NetUseGetInfo; external netapi32 name 'NetUseGetInfo';
  254. {$ENDIF DYNAMIC_LINK}
  255. {$ENDIF JWA_IMPLEMENTATIONSECTION}
  256. {$IFNDEF JWA_INCLUDEMODE}
  257. end.
  258. {$ENDIF !JWA_INCLUDEMODE}