Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing a folder programmatically and revoking it. (Delphi 7)

  1. How does one programmatically create a UNC share from a known directory?
  2. How does one revoke it programmatically?

I don't want the user to fiddle with the Share dialog. Additional info such as changing the share name, comment, user limit is also welcomed.

Thanks SoulBlade (Using Delphi 7)

like image 912
SoulBlade Avatar asked Jul 04 '26 07:07

SoulBlade


1 Answers

Create the share with NetShareAdd. This will share the directory with a null ACL, which is equavalent to allowing everyone full access.

Delete the share with NetShareDel.

Madshi's MadSecurity package has a helper which simplifies this down to:

NewShare(path, shareName, remark);
Share(shareName).Delete;
like image 116
glob Avatar answered Jul 06 '26 06:07

glob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!