我有个在2000下操作共享的例子,但用的不是netsharedel<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> Dir: string;<br>begin<br>try<br> Dir := 'C:/book';<br> if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],0) then<br> Edit1.text:= Dir;<br> //选择要共享的目录 <br>except<br>end;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br> str:string;<br>begin<br>if DirectoryExists(Edit1.text) then<br> begin<br> if edit2.text='' then<br> begin<br> showmessage('请指定共享名!');<br> //提示指定要删除的共享名<br> exit;<br> //退出Button2Click函数<br> end;<br> str:='command.com /C net share '+edit2.text+'='+edit1.text;<br> if cb1.Checked then<br> str:=str+' /UNLIMITED'<br> //同时访问人数无限制<br> else<br> str:=str+' /USERS:'+edit4.text;<br> //指定可同时访问人数<br> str:=str+' /REMARK:'+edit3.text;<br> case rg1.ItemIndex of<br> 0:str:=str+' /CACHE:Manual';<br> //手动配置缓存<br> 1:str:=str+' /CACHE:Automatic';<br> //自动配置缓存<br> 2:str:=str+' /CACHE:No';<br> //不需要缓存<br> end;<br><br> if winexec(pchar(str),sw_hide)>31 then<br> memo1.lines.add(edit1.text+'共享成功!')<br> else<br> memo1.lines.add(edit1.text+'共享失败!');<br> end;<br>end;<br><br>procedure TForm1.Edit1Change(Sender: TObject);<br>begin<br>edit2.text:=ExtractfileName(edit1.text);<br>end;<br><br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> memo1.Lines.Clear;<br>end;<br><br>procedure TForm1.edit4Change(Sender: TObject);<br>begin<br> try<br> strtoint(edit4.text);<br> except<br> showmessage('请输入整数!'); <br> end;<br>end;<br><br>procedure TForm1.cb1Enter(Sender: TObject);<br>begin<br>cb1.Checked:=not cb1.Checked;<br> //点击cb1后选择状态反转<br>end;<br><br>procedure TForm1.cb1Click(Sender: TObject);<br>begin<br> if cb1.Checked then<br> edit4.Enabled:=false<br> //不限制用户数则使edit4失效<br> else<br> edit4.Enabled:=true;<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>var<br> str:string;<br>begin<br>if DirectoryExists(Edit1.text) then<br> begin<br> if edit2.text='' then<br> begin<br> showmessage('请指定要取消的共享名!');<br> exit;<br> end;<br> str:='command.com /C net share '+edit2.text+' /delete';<br> if winexec(pchar(str),sw_hide)>31 then<br> memo1.lines.add(edit1.text+'共享取消!')<br> else<br> memo1.lines.add(edit1.text+'取消共享失败!');<br> end;<br>end;<br>end.