2
2days
Unregistered / Unconfirmed
GUEST, unregistred user!
大家好,我搜索到了,这个贴子<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1281458<br>然后照着里面的做了<br>可是运行后,总是提示Error:124,请问哪里错了,是什么问题<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>const<br> NETNAME_LEN = 13;<br> PASSWORD_LEN = 9;<br><br> SHI50F_RDONLY = $0001;<br> SHI50F_FULL = $0002;<br> SHI50F_DEPENDSON = $0003;<br> SHI50F_ACCESSMASK = $0003;<br> SHI50F_PERSIST = $0100;<br> SHI50F_SYSTEM = $0200;<br><br> STYPE_DISKTREE = 0;<br> STYPE_PRINTQ = 1;<br> STYPE_DEVICE = 2;<br> STYPE_IPC = 3;<br><br> NERR_Success = 0;<br> NERR_BASE = 2100; //常量说明<br> NERR_UnKnownDevDir = (NERR_BASE + 16);<br> NERR_UnknownServer = (NERR_BASE + 3);<br> NERR_ServerNotStarted = (NERR_BASE + 14);<br> NERR_RedirectedPath = (NERR_BASE + 17);<br> NERR_DuplicateShare = (NERR_BASE + 18);<br> NERR_BufTooSmalll = (NERR_BASE + 23);<br>type<br> TSHARE_INFO_50 = record<br> netname: array[0..NETNAME_LEN - 1] of Char;<br> sharetype: ShortInt;<br> flags: SmallInt;<br> remark: PChar;<br> path: PChar;<br> rw_password: array[0..PASSWORD_LEN - 1] of Char;<br> ro_password: array[0..PASSWORD_LEN - 1] of Char;<br> end; //以上为类型定义<br><br>function NetShareAdd(ServerName: PWideString; Level: Dword;<br> Buffer: pByte; ParamError: pDword): SmallInt;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br>function NetShareAdd; external 'svrapi.DLL' name 'NetShareAdd';<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> i: integer;<br> si: TSHARE_INFO_50;<br> parm_err: DWord;<br>begin<br> si.netname := 'save';<br> si.shareType := STYPE_DISKTREE;<br> si.flags := SHI50F_FULL;<br> si.remark := nil;<br> si.path := 'D:/temp/';<br> si.rw_password := '';<br> si.ro_password := '';<br> i := NetShareAdd(nil, 50, pbyte(@si), @parm_err);<br> if (i <> NERR_Success) then<br> showmessage('Error:' + inttostr(i));<br>end;<br>end.<br>