jwalmshare.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. {******************************************************************************}
  2. { }
  3. { Lan Manager Shares 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: lmshare.h, released November 2001. The original Pascal }
  9. { code is: LmShare.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 JwaLmShare;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "lmshare.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaLmCons, JwaWinNT, JwaWinType;
  51. //
  52. // Function Prototypes - Share
  53. //
  54. function NetShareAdd(servername: LMSTR; level: DWORD; buf: LPBYTE; parm_err: LPDWORD): NET_API_STATUS; stdcall;
  55. {$EXTERNALSYM NetShareAdd}
  56. function NetShareEnum(servername: LMSTR; level: DWORD; var bufptr: LPBYTE; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; stdcall;
  57. {$EXTERNALSYM NetShareEnum}
  58. function NetShareEnumSticky(servername: LMSTR; level: DWORD; var bufptr: LPBYTE; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; stdcall;
  59. {$EXTERNALSYM NetShareEnumSticky}
  60. function NetShareGetInfo(servername, netname: LMSTR; level: DWORD; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
  61. {$EXTERNALSYM NetShareGetInfo}
  62. function NetShareSetInfo(servername, netname: LMSTR; level: DWORD; buf: LPBYTE; parm_err: LPDWORD): NET_API_STATUS; stdcall;
  63. {$EXTERNALSYM NetShareSetInfo}
  64. function NetShareDel(servername, netname: LMSTR; reserved: DWORD): NET_API_STATUS; stdcall;
  65. {$EXTERNALSYM NetShareDel}
  66. function NetShareDelSticky(servername, netname: LMSTR; reserved: DWORD): NET_API_STATUS; stdcall;
  67. {$EXTERNALSYM NetShareDelSticky}
  68. function NetShareCheck(servername, device: LMSTR; type_: LPDWORD): NET_API_STATUS; stdcall;
  69. {$EXTERNALSYM NetShareCheck}
  70. //
  71. // Data Structures - Share
  72. //
  73. type
  74. LPSHARE_INFO_0 = ^SHARE_INFO_0;
  75. {$EXTERNALSYM LPSHARE_INFO_0}
  76. PSHARE_INFO_0 = ^SHARE_INFO_0;
  77. {$EXTERNALSYM PSHARE_INFO_0}
  78. _SHARE_INFO_0 = record
  79. shi0_netname: LMSTR;
  80. end;
  81. {$EXTERNALSYM _SHARE_INFO_0}
  82. SHARE_INFO_0 = _SHARE_INFO_0;
  83. {$EXTERNALSYM SHARE_INFO_0}
  84. TShareInfo0 = SHARE_INFO_0;
  85. PShareInfo0 = PSHARE_INFO_0;
  86. LPSHARE_INFO_1 = ^SHARE_INFO_1;
  87. {$EXTERNALSYM LPSHARE_INFO_1}
  88. PSHARE_INFO_1 = ^SHARE_INFO_1;
  89. {$EXTERNALSYM PSHARE_INFO_1}
  90. _SHARE_INFO_1 = record
  91. shi1_netname: LMSTR;
  92. shi1_type: DWORD;
  93. shi1_remark: LMSTR;
  94. end;
  95. {$EXTERNALSYM _SHARE_INFO_1}
  96. SHARE_INFO_1 = _SHARE_INFO_1;
  97. {$EXTERNALSYM SHARE_INFO_1}
  98. TShareInfo1 = SHARE_INFO_1;
  99. PShareInfo1 = PSHARE_INFO_1;
  100. LPSHARE_INFO_2 = ^SHARE_INFO_2;
  101. {$EXTERNALSYM LPSHARE_INFO_2}
  102. PSHARE_INFO_2 = ^SHARE_INFO_2;
  103. {$EXTERNALSYM PSHARE_INFO_2}
  104. _SHARE_INFO_2 = record
  105. shi2_netname: LMSTR;
  106. shi2_type: DWORD;
  107. shi2_remark: LMSTR;
  108. shi2_permissions: DWORD;
  109. shi2_max_uses: DWORD;
  110. shi2_current_uses: DWORD;
  111. shi2_path: LMSTR;
  112. shi2_passwd: LMSTR;
  113. end;
  114. {$EXTERNALSYM _SHARE_INFO_2}
  115. SHARE_INFO_2 = _SHARE_INFO_2;
  116. {$EXTERNALSYM SHARE_INFO_2}
  117. TShareInfo2 = SHARE_INFO_2;
  118. PShareInfo2 = PSHARE_INFO_2;
  119. LPSHARE_INFO_501 = ^SHARE_INFO_501;
  120. {$EXTERNALSYM LPSHARE_INFO_501}
  121. PSHARE_INFO_501 = ^SHARE_INFO_501;
  122. {$EXTERNALSYM PSHARE_INFO_501}
  123. _SHARE_INFO_501 = record
  124. shi501_netname: LMSTR;
  125. shi501_type: DWORD;
  126. shi501_remark: LMSTR;
  127. shi501_flags: DWORD;
  128. end;
  129. {$EXTERNALSYM _SHARE_INFO_501}
  130. SHARE_INFO_501 = _SHARE_INFO_501;
  131. {$EXTERNALSYM SHARE_INFO_501}
  132. TShareInfo501 = SHARE_INFO_501;
  133. PShareInfo501 = PSHARE_INFO_501;
  134. LPSHARE_INFO_502 = ^SHARE_INFO_502;
  135. {$EXTERNALSYM LPSHARE_INFO_502}
  136. PSHARE_INFO_502 = ^SHARE_INFO_502;
  137. {$EXTERNALSYM PSHARE_INFO_502}
  138. _SHARE_INFO_502 = record
  139. shi502_netname: LMSTR;
  140. shi502_type: DWORD;
  141. shi502_remark: LMSTR;
  142. shi502_permissions: DWORD;
  143. shi502_max_uses: DWORD;
  144. shi502_current_uses: DWORD;
  145. shi502_path: LMSTR;
  146. shi502_passwd: LMSTR;
  147. shi502_reserved: DWORD;
  148. shi502_security_descriptor: PSECURITY_DESCRIPTOR;
  149. end;
  150. {$EXTERNALSYM _SHARE_INFO_502}
  151. SHARE_INFO_502 = _SHARE_INFO_502;
  152. {$EXTERNALSYM SHARE_INFO_502}
  153. TShareInfo502 = SHARE_INFO_502;
  154. PShareInfo502 = PSHARE_INFO_502;
  155. LPSHARE_INFO_1004 = ^SHARE_INFO_1004;
  156. {$EXTERNALSYM LPSHARE_INFO_1004}
  157. PSHARE_INFO_1004 = ^SHARE_INFO_1004;
  158. {$EXTERNALSYM PSHARE_INFO_1004}
  159. _SHARE_INFO_1004 = record
  160. shi1004_remark: LMSTR;
  161. end;
  162. {$EXTERNALSYM _SHARE_INFO_1004}
  163. SHARE_INFO_1004 = _SHARE_INFO_1004;
  164. {$EXTERNALSYM SHARE_INFO_1004}
  165. TShareInfo1004 = SHARE_INFO_1004;
  166. PShareInfo1004 = PSHARE_INFO_1004;
  167. LPSHARE_INFO_1005 = ^SHARE_INFO_1005;
  168. {$EXTERNALSYM LPSHARE_INFO_1005}
  169. PSHARE_INFO_1005 = ^SHARE_INFO_1005;
  170. {$EXTERNALSYM PSHARE_INFO_1005}
  171. _SHARE_INFO_1005 = record
  172. shi1005_flags: DWORD;
  173. end;
  174. {$EXTERNALSYM _SHARE_INFO_1005}
  175. SHARE_INFO_1005 = _SHARE_INFO_1005;
  176. {$EXTERNALSYM SHARE_INFO_1005}
  177. TShareInfo1005 = SHARE_INFO_1005;
  178. PShareInfo1005 = PSHARE_INFO_1005;
  179. LPSHARE_INFO_1006 = ^SHARE_INFO_1006;
  180. {$EXTERNALSYM LPSHARE_INFO_1006}
  181. PSHARE_INFO_1006 = ^SHARE_INFO_1006;
  182. {$EXTERNALSYM PSHARE_INFO_1006}
  183. _SHARE_INFO_1006 = record
  184. shi1006_max_uses: DWORD;
  185. end;
  186. {$EXTERNALSYM _SHARE_INFO_1006}
  187. SHARE_INFO_1006 = _SHARE_INFO_1006;
  188. {$EXTERNALSYM SHARE_INFO_1006}
  189. TShareInfo1006 = SHARE_INFO_1006;
  190. PShareInfo1006 = PSHARE_INFO_1006;
  191. LPSHARE_INFO_1501 = ^SHARE_INFO_1501;
  192. {$EXTERNALSYM LPSHARE_INFO_1501}
  193. PSHARE_INFO_1501 = ^SHARE_INFO_1501;
  194. {$EXTERNALSYM PSHARE_INFO_1501}
  195. _SHARE_INFO_1501 = record
  196. shi1501_reserved: DWORD;
  197. shi1501_security_descriptor: PSECURITY_DESCRIPTOR;
  198. end;
  199. {$EXTERNALSYM _SHARE_INFO_1501}
  200. SHARE_INFO_1501 = _SHARE_INFO_1501;
  201. {$EXTERNALSYM SHARE_INFO_1501}
  202. TShareInfo1501 = SHARE_INFO_1501;
  203. PShareInfo1501 = PSHARE_INFO_1501;
  204. //
  205. // Special Values and Constants - Share
  206. //
  207. //
  208. // Values for parm_err parameter.
  209. //
  210. const
  211. SHARE_NETNAME_PARMNUM = 1;
  212. {$EXTERNALSYM SHARE_NETNAME_PARMNUM}
  213. SHARE_TYPE_PARMNUM = 3;
  214. {$EXTERNALSYM SHARE_TYPE_PARMNUM}
  215. SHARE_REMARK_PARMNUM = 4;
  216. {$EXTERNALSYM SHARE_REMARK_PARMNUM}
  217. SHARE_PERMISSIONS_PARMNUM = 5;
  218. {$EXTERNALSYM SHARE_PERMISSIONS_PARMNUM}
  219. SHARE_MAX_USES_PARMNUM = 6;
  220. {$EXTERNALSYM SHARE_MAX_USES_PARMNUM}
  221. SHARE_CURRENT_USES_PARMNUM = 7;
  222. {$EXTERNALSYM SHARE_CURRENT_USES_PARMNUM}
  223. SHARE_PATH_PARMNUM = 8;
  224. {$EXTERNALSYM SHARE_PATH_PARMNUM}
  225. SHARE_PASSWD_PARMNUM = 9;
  226. {$EXTERNALSYM SHARE_PASSWD_PARMNUM}
  227. SHARE_FILE_SD_PARMNUM = 501;
  228. {$EXTERNALSYM SHARE_FILE_SD_PARMNUM}
  229. //
  230. // Single-field infolevels for NetShareSetInfo.
  231. //
  232. SHARE_REMARK_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + SHARE_REMARK_PARMNUM;
  233. {$EXTERNALSYM SHARE_REMARK_INFOLEVEL}
  234. SHARE_MAX_USES_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + SHARE_MAX_USES_PARMNUM;
  235. {$EXTERNALSYM SHARE_MAX_USES_INFOLEVEL}
  236. SHARE_FILE_SD_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + SHARE_FILE_SD_PARMNUM;
  237. {$EXTERNALSYM SHARE_FILE_SD_INFOLEVEL}
  238. SHI1_NUM_ELEMENTS = 4;
  239. {$EXTERNALSYM SHI1_NUM_ELEMENTS}
  240. SHI2_NUM_ELEMENTS = 10;
  241. {$EXTERNALSYM SHI2_NUM_ELEMENTS}
  242. //
  243. // Share types (shi1_type and shi2_type fields).
  244. //
  245. STYPE_DISKTREE = 0;
  246. {$EXTERNALSYM STYPE_DISKTREE}
  247. STYPE_PRINTQ = 1;
  248. {$EXTERNALSYM STYPE_PRINTQ}
  249. STYPE_DEVICE = 2;
  250. {$EXTERNALSYM STYPE_DEVICE}
  251. STYPE_IPC = 3;
  252. {$EXTERNALSYM STYPE_IPC}
  253. STYPE_TEMPORARY = $40000000;
  254. {$EXTERNALSYM STYPE_TEMPORARY}
  255. STYPE_SPECIAL = DWORD($80000000);
  256. {$EXTERNALSYM STYPE_SPECIAL}
  257. SHI_USES_UNLIMITED = DWORD(-1);
  258. {$EXTERNALSYM SHI_USES_UNLIMITED}
  259. //
  260. // Flags values for the 501 and 1005 levels
  261. //
  262. SHI1005_FLAGS_DFS = $01; // Share is in the DFS
  263. {$EXTERNALSYM SHI1005_FLAGS_DFS}
  264. SHI1005_FLAGS_DFS_ROOT = $02; // Share is root of DFS
  265. {$EXTERNALSYM SHI1005_FLAGS_DFS_ROOT}
  266. CSC_MASK = $30; // Used to mask off the following states
  267. {$EXTERNALSYM CSC_MASK}
  268. CSC_CACHE_MANUAL_REINT = $00; // No automatic file by file reintegration
  269. {$EXTERNALSYM CSC_CACHE_MANUAL_REINT}
  270. CSC_CACHE_AUTO_REINT = $10; // File by file reintegration is OK
  271. {$EXTERNALSYM CSC_CACHE_AUTO_REINT}
  272. CSC_CACHE_VDO = $20; // no need to flow opens
  273. {$EXTERNALSYM CSC_CACHE_VDO}
  274. CSC_CACHE_NONE = $30; // no CSC for this share
  275. {$EXTERNALSYM CSC_CACHE_NONE}
  276. SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS = $0100; // Used to disallow read-deny read behavior
  277. {$EXTERNALSYM SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS}
  278. SHI1005_FLAGS_FORCE_SHARED_DELETE = $0200; // Used to allows force shared delete
  279. {$EXTERNALSYM SHI1005_FLAGS_FORCE_SHARED_DELETE}
  280. SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING = $0400; // The clients may cache the namespace
  281. {$EXTERNALSYM SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING}
  282. //
  283. // The subset of 1005 infolevel flags that can be set via the API
  284. //
  285. SHI1005_VALID_FLAGS_SET = CSC_MASK or SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS or SHI1005_FLAGS_FORCE_SHARED_DELETE or SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING;
  286. {$EXTERNALSYM SHI1005_VALID_FLAGS_SET}
  287. //
  288. // SESSION API
  289. //
  290. //
  291. // Function Prototypes Session
  292. //
  293. function NetSessionEnum(servername, UncClientName, username: LMSTR; level: DWORD; var bufptr: LPBYTE; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; stdcall;
  294. {$EXTERNALSYM NetSessionEnum}
  295. function NetSessionDel(servername, UncClientName, username: LMSTR): NET_API_STATUS; stdcall;
  296. {$EXTERNALSYM NetSessionDel}
  297. function NetSessionGetInfo(servername, UncClientName, username: LMSTR; level: DWORD; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
  298. {$EXTERNALSYM NetSessionGetInfo}
  299. //
  300. // Data Structures - Session
  301. //
  302. type
  303. LPSESSION_INFO_0 = ^SESSION_INFO_0;
  304. {$EXTERNALSYM LPSESSION_INFO_0}
  305. PSESSION_INFO_0 = ^SESSION_INFO_0;
  306. {$EXTERNALSYM PSESSION_INFO_0}
  307. _SESSION_INFO_0 = record
  308. sesi0_cname: LMSTR; // client name (no backslashes)
  309. end;
  310. {$EXTERNALSYM _SESSION_INFO_0}
  311. SESSION_INFO_0 = _SESSION_INFO_0;
  312. {$EXTERNALSYM SESSION_INFO_0}
  313. TSessionInfo0 = SESSION_INFO_0;
  314. PSessionInfo0 = PSESSION_INFO_0;
  315. LPSESSION_INFO_1 = ^SESSION_INFO_1;
  316. {$EXTERNALSYM LPSESSION_INFO_1}
  317. PSESSION_INFO_1 = ^SESSION_INFO_1;
  318. {$EXTERNALSYM PSESSION_INFO_1}
  319. _SESSION_INFO_1 = record
  320. sesi1_cname: LMSTR; // client name (no backslashes)
  321. sesi1_username: LMSTR;
  322. sesi1_num_opens: DWORD;
  323. sesi1_time: DWORD;
  324. sesi1_idle_time: DWORD;
  325. sesi1_user_flags: DWORD;
  326. end;
  327. {$EXTERNALSYM _SESSION_INFO_1}
  328. SESSION_INFO_1 = _SESSION_INFO_1;
  329. {$EXTERNALSYM SESSION_INFO_1}
  330. TSessionInfo1 = SESSION_INFO_1;
  331. PSessionInfo1 = PSESSION_INFO_1;
  332. LPSESSION_INFO_2 = ^SESSION_INFO_2;
  333. {$EXTERNALSYM LPSESSION_INFO_2}
  334. PSESSION_INFO_2 = ^SESSION_INFO_2;
  335. {$EXTERNALSYM PSESSION_INFO_2}
  336. _SESSION_INFO_2 = record
  337. sesi2_cname: LMSTR; // client name (no backslashes)
  338. sesi2_username: LMSTR;
  339. sesi2_num_opens: DWORD;
  340. sesi2_time: DWORD;
  341. sesi2_idle_time: DWORD;
  342. sesi2_user_flags: DWORD;
  343. sesi2_cltype_name: LMSTR;
  344. end;
  345. {$EXTERNALSYM _SESSION_INFO_2}
  346. SESSION_INFO_2 = _SESSION_INFO_2;
  347. {$EXTERNALSYM SESSION_INFO_2}
  348. TSessionInfo2 = SESSION_INFO_2;
  349. PSessionInfo2 = PSESSION_INFO_2;
  350. LPSESSION_INFO_10 = ^SESSION_INFO_10;
  351. {$EXTERNALSYM LPSESSION_INFO_10}
  352. PSESSION_INFO_10 = ^SESSION_INFO_10;
  353. {$EXTERNALSYM PSESSION_INFO_10}
  354. _SESSION_INFO_10 = record
  355. sesi10_cname: LMSTR; // client name (no backslashes)
  356. sesi10_username: LMSTR;
  357. sesi10_time: DWORD;
  358. sesi10_idle_time: DWORD;
  359. end;
  360. {$EXTERNALSYM _SESSION_INFO_10}
  361. SESSION_INFO_10 = _SESSION_INFO_10;
  362. {$EXTERNALSYM SESSION_INFO_10}
  363. TSessionInfo10 = SESSION_INFO_10;
  364. PSessionInfo10 = PSESSION_INFO_10;
  365. LPSESSION_INFO_502 = ^SESSION_INFO_502;
  366. {$EXTERNALSYM LPSESSION_INFO_502}
  367. PSESSION_INFO_502 = ^SESSION_INFO_502;
  368. {$EXTERNALSYM PSESSION_INFO_502}
  369. _SESSION_INFO_502 = record
  370. sesi502_cname: LMSTR; // client name (no backslashes)
  371. sesi502_username: LMSTR;
  372. sesi502_num_opens: DWORD;
  373. sesi502_time: DWORD;
  374. sesi502_idle_time: DWORD;
  375. sesi502_user_flags: DWORD;
  376. sesi502_cltype_name: LMSTR;
  377. sesi502_transport: LMSTR;
  378. end;
  379. {$EXTERNALSYM _SESSION_INFO_502}
  380. SESSION_INFO_502 = _SESSION_INFO_502;
  381. {$EXTERNALSYM SESSION_INFO_502}
  382. TSessionInfo502 = SESSION_INFO_502;
  383. PSessionInfo502 = PSESSION_INFO_502;
  384. //
  385. // Special Values and Constants - Session
  386. //
  387. //
  388. // Bits defined in sesi1_user_flags.
  389. //
  390. const
  391. SESS_GUEST = $00000001; // session is logged on as a guest
  392. {$EXTERNALSYM SESS_GUEST}
  393. SESS_NOENCRYPTION = $00000002; // session is not using encryption
  394. {$EXTERNALSYM SESS_NOENCRYPTION}
  395. SESI1_NUM_ELEMENTS = 8;
  396. {$EXTERNALSYM SESI1_NUM_ELEMENTS}
  397. SESI2_NUM_ELEMENTS = 9;
  398. {$EXTERNALSYM SESI2_NUM_ELEMENTS}
  399. //
  400. // CONNECTION API
  401. //
  402. //
  403. // Function Prototypes - CONNECTION
  404. //
  405. function NetConnectionEnum(servername, qualifier: LMSTR; level: DWORD; var bufptr: LPBYTE; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; stdcall;
  406. {$EXTERNALSYM NetConnectionEnum}
  407. //
  408. // Data Structures - CONNECTION
  409. //
  410. type
  411. LPCONNECTION_INFO_0 = ^CONNECTION_INFO_0;
  412. {$EXTERNALSYM LPCONNECTION_INFO_0}
  413. PCONNECTION_INFO_0 = ^CONNECTION_INFO_0;
  414. {$EXTERNALSYM PCONNECTION_INFO_0}
  415. _CONNECTION_INFO_0 = record
  416. coni0_id: DWORD;
  417. end;
  418. {$EXTERNALSYM _CONNECTION_INFO_0}
  419. CONNECTION_INFO_0 = _CONNECTION_INFO_0;
  420. {$EXTERNALSYM CONNECTION_INFO_0}
  421. TConnectionInfo0 = CONNECTION_INFO_0;
  422. PConnectionInfo0 = PCONNECTION_INFO_0;
  423. LPCONNECTION_INFO_1 = ^CONNECTION_INFO_1;
  424. {$EXTERNALSYM LPCONNECTION_INFO_1}
  425. PCONNECTION_INFO_1 = ^CONNECTION_INFO_1;
  426. {$EXTERNALSYM PCONNECTION_INFO_1}
  427. _CONNECTION_INFO_1 = record
  428. coni1_id: DWORD;
  429. coni1_type: DWORD;
  430. coni1_num_opens: DWORD;
  431. coni1_num_users: DWORD;
  432. coni1_time: DWORD;
  433. coni1_username: LMSTR;
  434. coni1_netname: LMSTR;
  435. end;
  436. {$EXTERNALSYM _CONNECTION_INFO_1}
  437. CONNECTION_INFO_1 = _CONNECTION_INFO_1;
  438. {$EXTERNALSYM CONNECTION_INFO_1}
  439. TConnectionInfo1 = CONNECTION_INFO_1;
  440. PConnectionInfo1 = PCONNECTION_INFO_1;
  441. //
  442. // FILE API
  443. //
  444. //
  445. // Function Prototypes - FILE
  446. //
  447. function NetFileClose(servername: LMSTR; fileid: DWORD): NET_API_STATUS; stdcall;
  448. {$EXTERNALSYM NetFileClose}
  449. function NetFileEnum(servername, basepath, username: LMSTR; level: DWORD; var bufptr: LPBYTE; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: PDWORD_PTR): NET_API_STATUS; stdcall;
  450. {$EXTERNALSYM NetFileEnum}
  451. function NetFileGetInfo(servername: LMSTR; fileid, level: DWORD; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
  452. {$EXTERNALSYM NetFileGetInfo}
  453. //
  454. // Data Structures - File
  455. //
  456. // File APIs are available at information levels 2 & 3 only. Levels 0 &
  457. // 1 are not supported.
  458. //
  459. type
  460. LPFILE_INFO_2 = ^FILE_INFO_2;
  461. {$EXTERNALSYM LPFILE_INFO_2}
  462. PFILE_INFO_2 = ^FILE_INFO_2;
  463. {$EXTERNALSYM PFILE_INFO_2}
  464. _FILE_INFO_2 = record
  465. fi2_id: DWORD;
  466. end;
  467. {$EXTERNALSYM _FILE_INFO_2}
  468. FILE_INFO_2 = _FILE_INFO_2;
  469. {$EXTERNALSYM FILE_INFO_2}
  470. TFileInfo2 = FILE_INFO_2;
  471. PFileInfo2 = PFILE_INFO_2;
  472. LPFILE_INFO_3 = ^FILE_INFO_3;
  473. {$EXTERNALSYM LPFILE_INFO_3}
  474. PFILE_INFO_3 = ^FILE_INFO_3;
  475. {$EXTERNALSYM PFILE_INFO_3}
  476. _FILE_INFO_3 = record
  477. fi3_id: DWORD;
  478. fi3_permissions: DWORD;
  479. fi3_num_locks: DWORD;
  480. fi3_pathname: LMSTR;
  481. fi3_username: LMSTR;
  482. end;
  483. {$EXTERNALSYM _FILE_INFO_3}
  484. FILE_INFO_3 = _FILE_INFO_3;
  485. {$EXTERNALSYM FILE_INFO_3}
  486. TFileInfo3 = FILE_INFO_3;
  487. PFileInfo3 = PFILE_INFO_3;
  488. //
  489. // Special Values and Constants - File
  490. //
  491. //
  492. // bit values for permissions
  493. //
  494. const
  495. PERM_FILE_READ = $1; // user has read access
  496. {$EXTERNALSYM PERM_FILE_READ}
  497. PERM_FILE_WRITE = $2; // user has write access
  498. {$EXTERNALSYM PERM_FILE_WRITE}
  499. PERM_FILE_CREATE = $4; // user has create access
  500. {$EXTERNALSYM PERM_FILE_CREATE}
  501. implementation
  502. {$IFDEF DYNAMIC_LINK}
  503. var
  504. _NetShareAdd: Pointer;
  505. function NetShareAdd;
  506. begin
  507. GetProcedureAddress(_NetShareAdd, netapi32, 'NetShareAdd');
  508. asm
  509. MOV ESP, EBP
  510. POP EBP
  511. JMP [_NetShareAdd]
  512. end;
  513. end;
  514. var
  515. _NetShareEnum: Pointer;
  516. function NetShareEnum;
  517. begin
  518. GetProcedureAddress(_NetShareEnum, netapi32, 'NetShareEnum');
  519. asm
  520. MOV ESP, EBP
  521. POP EBP
  522. JMP [_NetShareEnum]
  523. end;
  524. end;
  525. var
  526. _NetShareEnumSticky: Pointer;
  527. function NetShareEnumSticky;
  528. begin
  529. GetProcedureAddress(_NetShareEnumSticky, netapi32, 'NetShareEnumSticky');
  530. asm
  531. MOV ESP, EBP
  532. POP EBP
  533. JMP [_NetShareEnumSticky]
  534. end;
  535. end;
  536. var
  537. _NetShareGetInfo: Pointer;
  538. function NetShareGetInfo;
  539. begin
  540. GetProcedureAddress(_NetShareGetInfo, netapi32, 'NetShareGetInfo');
  541. asm
  542. MOV ESP, EBP
  543. POP EBP
  544. JMP [_NetShareGetInfo]
  545. end;
  546. end;
  547. var
  548. _NetShareSetInfo: Pointer;
  549. function NetShareSetInfo;
  550. begin
  551. GetProcedureAddress(_NetShareSetInfo, netapi32, 'NetShareSetInfo');
  552. asm
  553. MOV ESP, EBP
  554. POP EBP
  555. JMP [_NetShareSetInfo]
  556. end;
  557. end;
  558. var
  559. _NetShareDel: Pointer;
  560. function NetShareDel;
  561. begin
  562. GetProcedureAddress(_NetShareDel, netapi32, 'NetShareDel');
  563. asm
  564. MOV ESP, EBP
  565. POP EBP
  566. JMP [_NetShareDel]
  567. end;
  568. end;
  569. var
  570. _NetShareDelSticky: Pointer;
  571. function NetShareDelSticky;
  572. begin
  573. GetProcedureAddress(_NetShareDelSticky, netapi32, 'NetShareDelSticky');
  574. asm
  575. MOV ESP, EBP
  576. POP EBP
  577. JMP [_NetShareDelSticky]
  578. end;
  579. end;
  580. var
  581. _NetShareCheck: Pointer;
  582. function NetShareCheck;
  583. begin
  584. GetProcedureAddress(_NetShareCheck, netapi32, 'NetShareCheck');
  585. asm
  586. MOV ESP, EBP
  587. POP EBP
  588. JMP [_NetShareCheck]
  589. end;
  590. end;
  591. var
  592. _NetSessionEnum: Pointer;
  593. function NetSessionEnum;
  594. begin
  595. GetProcedureAddress(_NetSessionEnum, netapi32, 'NetSessionEnum');
  596. asm
  597. MOV ESP, EBP
  598. POP EBP
  599. JMP [_NetSessionEnum]
  600. end;
  601. end;
  602. var
  603. _NetSessionDel: Pointer;
  604. function NetSessionDel;
  605. begin
  606. GetProcedureAddress(_NetSessionDel, netapi32, 'NetSessionDel');
  607. asm
  608. MOV ESP, EBP
  609. POP EBP
  610. JMP [_NetSessionDel]
  611. end;
  612. end;
  613. var
  614. _NetSessionGetInfo: Pointer;
  615. function NetSessionGetInfo;
  616. begin
  617. GetProcedureAddress(_NetSessionGetInfo, netapi32, 'NetSessionGetInfo');
  618. asm
  619. MOV ESP, EBP
  620. POP EBP
  621. JMP [_NetSessionGetInfo]
  622. end;
  623. end;
  624. var
  625. _NetConnectionEnum: Pointer;
  626. function NetConnectionEnum;
  627. begin
  628. GetProcedureAddress(_NetConnectionEnum, netapi32, 'NetConnectionEnum');
  629. asm
  630. MOV ESP, EBP
  631. POP EBP
  632. JMP [_NetConnectionEnum]
  633. end;
  634. end;
  635. var
  636. _NetFileClose: Pointer;
  637. function NetFileClose;
  638. begin
  639. GetProcedureAddress(_NetFileClose, netapi32, 'NetFileClose');
  640. asm
  641. MOV ESP, EBP
  642. POP EBP
  643. JMP [_NetFileClose]
  644. end;
  645. end;
  646. var
  647. _NetFileEnum: Pointer;
  648. function NetFileEnum;
  649. begin
  650. GetProcedureAddress(_NetFileEnum, netapi32, 'NetFileEnum');
  651. asm
  652. MOV ESP, EBP
  653. POP EBP
  654. JMP [_NetFileEnum]
  655. end;
  656. end;
  657. var
  658. _NetFileGetInfo: Pointer;
  659. function NetFileGetInfo;
  660. begin
  661. GetProcedureAddress(_NetFileGetInfo, netapi32, 'NetFileGetInfo');
  662. asm
  663. MOV ESP, EBP
  664. POP EBP
  665. JMP [_NetFileGetInfo]
  666. end;
  667. end;
  668. {$ELSE}
  669. function NetShareAdd; external netapi32 name 'NetShareAdd';
  670. function NetShareEnum; external netapi32 name 'NetShareEnum';
  671. function NetShareEnumSticky; external netapi32 name 'NetShareEnumSticky';
  672. function NetShareGetInfo; external netapi32 name 'NetShareGetInfo';
  673. function NetShareSetInfo; external netapi32 name 'NetShareSetInfo';
  674. function NetShareDel; external netapi32 name 'NetShareDel';
  675. function NetShareDelSticky; external netapi32 name 'NetShareDelSticky';
  676. function NetShareCheck; external netapi32 name 'NetShareCheck';
  677. function NetSessionEnum; external netapi32 name 'NetSessionEnum';
  678. function NetSessionDel; external netapi32 name 'NetSessionDel';
  679. function NetSessionGetInfo; external netapi32 name 'NetSessionGetInfo';
  680. function NetConnectionEnum; external netapi32 name 'NetConnectionEnum';
  681. function NetFileClose; external netapi32 name 'NetFileClose';
  682. function NetFileEnum; external netapi32 name 'NetFileEnum';
  683. function NetFileGetInfo; external netapi32 name 'NetFileGetInfo';
  684. {$ENDIF DYNAMIC_LINK}
  685. end.