WIN98下如何用NetShareAdd共享目录?(急急急)(200分)

  • 主题发起人 主题发起人 kinn_liu
  • 开始时间 开始时间
K

kinn_liu

Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序如下,在WIN98下总是不能共享目录<br><br>该程序在2K下能正常运行,定向动态库到netapi.dll上后,正常运行。<br>我怀疑是函数定义处数据类型不匹配造成的。<br><br>请诸位大虾参详!!!<br><br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; private<br>&nbsp; public<br>&nbsp; end;{略}<br><br>TSHARE_INFO_502 = record<br>&nbsp; &nbsp; shi502_netname: PWideChar;<br>&nbsp; &nbsp; shi502_type: DWORD;<br>&nbsp; &nbsp; shi502_remark: PWideChar;<br>&nbsp; &nbsp; shi502_permissions: DWORD;<br>&nbsp; &nbsp; shi502_max_uses: DWORD;<br>&nbsp; &nbsp; shi502_current_uses: DWORD;<br>&nbsp; &nbsp; shi502_path: PWideChar;<br>&nbsp; &nbsp; shi502_passwd: PWideChar;<br>&nbsp; &nbsp; shi502_reserved: DWORD;<br>&nbsp; &nbsp; shi502_security_descriptor: PSECURITY_DESCRIPTOR;<br>&nbsp; end;<br><br>&nbsp; PBYTE = ^BYTE;<br>&nbsp; PDWORD = ^DWORD;<br><br>function NetShareAdd(servername:WideString; level: DWORD; buf: PBYTE;var<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parm_err: LPDWORD &nbsp;): DWORD; stdcall;<br><br>。。。<br><br>implementation<br><br>function NetShareAdd; external 'svrapi.Dll' name 'NetShareAdd';<br>function NetShareDel; external 'svrapi.Dll' name 'NetShareDel';<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp; &nbsp; &nbsp; &nbsp; sharepath : WideString;<br>&nbsp; &nbsp; &nbsp; &nbsp; ServerName:WideString;<br>&nbsp; &nbsp; &nbsp; &nbsp; netname : widestring;<br>&nbsp; &nbsp; &nbsp; &nbsp; si: TSHARE_INFO_502;<br>&nbsp; &nbsp; &nbsp; &nbsp; r: smallint;<br>&nbsp; &nbsp; &nbsp; &nbsp; parm_err:smallint ;<br>begin<br>&nbsp; &nbsp; si.shi502_netname := Pwidechar(netname); &nbsp; //(共享名)<br>&nbsp; &nbsp; si.shi502_type := 0; &nbsp;//STYPE_DISKTREE<br>&nbsp; &nbsp; si.shi502_remark := nil;<br>&nbsp; &nbsp; si.shi502_max_uses := $FFFFFFFF;<br>&nbsp; &nbsp; si.shi502_current_uses := 10;<br><br>&nbsp; &nbsp; //对共享名的分析<br>&nbsp; &nbsp; sharepath := widestring(extractfilepath(edit_file.text));<br>&nbsp; &nbsp; si.shi502_path := Pwidechar(sharepath); &nbsp;// (原路径)<br>&nbsp; &nbsp; si.shi502_passwd := nil;<br>&nbsp; &nbsp; si.shi502_reserved := 0;<br>&nbsp; &nbsp; si.shi502_security_descriptor := nil;<br>&nbsp; &nbsp; si.shi502_permissions:=TRUSTEE_ACCESS_ALL;<br><br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; r := NetShareAdd(ServerName, 502, @si, parm_err ); &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; except<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; if r&lt;&gt; 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; showmessage('无法创建网络共享,请确认您登录的用户拥有该权限。');<br>&nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; //2.3删除共享<br>&nbsp; &nbsp; netsharedel(servername,netname,0);<br>end;
 
http://go4.163.com/lovejingtao/mysharescr.zip
 
请大虾们正面回答问题,帮助我提高一下水平。<br>谢谢。
 
从深度历险上DOWN了一个控件,看了一下原码,搞定了。<br>谢谢,大虾的支持。
 
shareing98.zip
 
后退
顶部