K
kinn_liu
Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序如下,在WIN98下总是不能共享目录<br><br>该程序在2K下能正常运行,定向动态库到netapi.dll上后,正常运行。<br>我怀疑是函数定义处数据类型不匹配造成的。<br><br>请诸位大虾参详!!!<br><br><br>type<br> TForm1 = class(TForm)<br> private<br> public<br> end;{略}<br><br>TSHARE_INFO_502 = record<br> shi502_netname: PWideChar;<br> shi502_type: DWORD;<br> shi502_remark: PWideChar;<br> shi502_permissions: DWORD;<br> shi502_max_uses: DWORD;<br> shi502_current_uses: DWORD;<br> shi502_path: PWideChar;<br> shi502_passwd: PWideChar;<br> shi502_reserved: DWORD;<br> shi502_security_descriptor: PSECURITY_DESCRIPTOR;<br> end;<br><br> PBYTE = ^BYTE;<br> PDWORD = ^DWORD;<br><br>function NetShareAdd(servername:WideString; level: DWORD; buf: PBYTE;var<br> parm_err: LPDWORD  : 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> sharepath : WideString;<br> ServerName:WideString;<br> netname : widestring;<br> si: TSHARE_INFO_502;<br> r: smallint;<br> parm_err:smallint ;<br>begin<br> si.shi502_netname := Pwidechar(netname); //(共享名)<br> si.shi502_type := 0; //STYPE_DISKTREE<br> si.shi502_remark := nil;<br> si.shi502_max_uses := $FFFFFFFF;<br> si.shi502_current_uses := 10;<br><br> //对共享名的分析<br> sharepath := widestring(extractfilepath(edit_file.text));<br> si.shi502_path := Pwidechar(sharepath); // (原路径)<br> si.shi502_passwd := nil;<br> si.shi502_reserved := 0;<br> si.shi502_security_descriptor := nil;<br> si.shi502_permissions:=TRUSTEE_ACCESS_ALL;<br><br> try<br> r := NetShareAdd(ServerName, 502, @si, parm_err ); <br> except<br> end;<br><br> if r<> 0 then<br> begin<br> showmessage('无法创建网络共享,请确认您登录的用户拥有该权限。');<br> exit;<br> end;<br><br> //2.3删除共享<br> netsharedel(servername,netname,0);<br>end;