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

Windows编程

开发平台:

Delphi

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