NetShareDel 在Win Nt/2000 下的用法(100分)

  • 主题发起人 主题发起人 HaiHong
  • 开始时间 开始时间
H

HaiHong

Unregistered / Unconfirmed
GUEST, unregistred user!
我在WIN98下用 NetShareDel 正常删除了一个网络共享资源<br><br>但在 WIN2000 Server 下却不能完成,错误为2310(共享资源名错误)<br><br>请大虾给出 NetShareDel 在Win Nt/2000 下的详细使用方法
 
function NetShareDel; external 'SVRAPI.DLL';<br>{注意:NT/2000下要改为NETAPI32.DLL,可以在程序中判断系统来加载不同的DLL }<br><br><br>
 
我有个在2000下操作共享的例子,但用的不是netsharedel<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; Dir: string;<br>begin<br>try<br>&nbsp; Dir := 'C:/book';<br>&nbsp; if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],0) then<br>&nbsp; &nbsp; Edit1.text:= Dir;<br>&nbsp; &nbsp; //选择要共享的目录 <br>except<br>end;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp;str:string;<br>begin<br>if DirectoryExists(Edit1.text) then<br>&nbsp; begin<br>&nbsp; &nbsp; if edit2.text='' then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;showmessage('请指定共享名!');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//提示指定要删除的共享名<br>&nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//退出Button2Click函数<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp;str:='command.com /C net share '+edit2.text+'='+edit1.text;<br>&nbsp; &nbsp;if cb1.Checked then<br>&nbsp; &nbsp; &nbsp;str:=str+' /UNLIMITED'<br>&nbsp; &nbsp; &nbsp; &nbsp; //同时访问人数无限制<br>&nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; str:=str+' /USERS:'+edit4.text;<br>&nbsp; &nbsp; &nbsp; &nbsp; //指定可同时访问人数<br>&nbsp; &nbsp; &nbsp; &nbsp; str:=str+' /REMARK:'+edit3.text;<br>&nbsp; &nbsp; case rg1.ItemIndex of<br>&nbsp; &nbsp; &nbsp; 0:str:=str+' /CACHE:Manual';<br>&nbsp; &nbsp; &nbsp; &nbsp;//手动配置缓存<br>&nbsp; &nbsp; &nbsp; 1:str:=str+' /CACHE:Automatic';<br>&nbsp; &nbsp; &nbsp; &nbsp;//自动配置缓存<br>&nbsp; &nbsp; &nbsp; 2:str:=str+' /CACHE:No';<br>&nbsp; &nbsp; &nbsp; &nbsp;//不需要缓存<br>&nbsp; &nbsp; &nbsp;end;<br><br>&nbsp; &nbsp;if winexec(pchar(str),sw_hide)&gt;31 then<br>&nbsp; &nbsp; memo1.lines.add(edit1.text+'共享成功!')<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp;memo1.lines.add(edit1.text+'共享失败!');<br>&nbsp; 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>&nbsp;memo1.Lines.Clear;<br>end;<br><br>procedure TForm1.edit4Change(Sender: TObject);<br>begin<br>&nbsp; try<br>&nbsp; &nbsp; strtoint(edit4.text);<br>&nbsp; except<br>&nbsp; &nbsp; showmessage('请输入整数!'); &nbsp; &nbsp;<br>&nbsp; end;<br>end;<br><br>procedure TForm1.cb1Enter(Sender: TObject);<br>begin<br>cb1.Checked:=not cb1.Checked;<br>&nbsp; //点击cb1后选择状态反转<br>end;<br><br>procedure TForm1.cb1Click(Sender: TObject);<br>begin<br>&nbsp;if cb1.Checked then<br>&nbsp; &nbsp; edit4.Enabled:=false<br>&nbsp; &nbsp; //不限制用户数则使edit4失效<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp;edit4.Enabled:=true;<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>var<br>&nbsp;str:string;<br>begin<br>if DirectoryExists(Edit1.text) then<br>&nbsp; begin<br>&nbsp; &nbsp; if edit2.text='' then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;showmessage('请指定要取消的共享名!');<br>&nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp;str:='command.com /C net share '+edit2.text+' /delete';<br>&nbsp; &nbsp;if winexec(pchar(str),sw_hide)&gt;31 then<br>&nbsp; &nbsp; memo1.lines.add(edit1.text+'共享取消!')<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp;memo1.lines.add(edit1.text+'取消共享失败!');<br>&nbsp; end;<br>end;<br>end.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
561
import
I
后退
顶部