S
supershan
Unregistered / Unconfirmed
GUEST, unregistred user!
我用NetShareAdd这个函数设置共享,在98下已经实现,但在NT/2000上无法实现
我用的DLL是NetApi32.dll,程序代码如下:请大家帮助找找错:
type
Share_Info502 = packed record
shi502_netname:LPTSTR;
shi502_typeWORD;
shi502_remark:LPSTR;
shi502_path:LPTSTR;
shi502_passwd:LPTSTR;
shi502_permissions: DWORD;
shi502_max_uses: DWORD;
shi502_current_uses: DWORD;
shi502_reserved: DWORD;
shi502_security_descriptor: PSECURITY_DESCRIPTOR;
end;
{WinNT/2000}
function ShareResourceEx(ServerNameChar;FilePathChar):Integer;
var
MyShare : Share_Info502;
PMyShare : ^Share_Info502;
begin
MyShare.shi502_netname:='CNVSHARE' {共享名称}
MyShare.shi502_type := STYPE_DISKTREE; {共享类型:0:共享目录;1:共享打印机}
MyShare.shi502_remark := 'HELLO'; {备注}
MyShare.shi502_path := FilePath; {共享目录}
MyShare.shi502_permissions:=0; {许可}
MyShare.shi502_max_uses:= 5; {同时连接用户数}
MyShare.shi502_current_uses:=10; {可连接用户数}
MyShare.shi502_reserved:=0;
MyShare.shi502_security_descriptor:=nil;
MyShare.shi502_PassWd:=''; {口令}
PMyShare := @MyShare;
Result := NetShareAdd(ServerName,502,PMyShare,SizeOf(MyShare));
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ShareResourceEx(nil, pchar(UpperCase(Edit1.Text)));
end;
我用的DLL是NetApi32.dll,程序代码如下:请大家帮助找找错:
type
Share_Info502 = packed record
shi502_netname:LPTSTR;
shi502_typeWORD;
shi502_remark:LPSTR;
shi502_path:LPTSTR;
shi502_passwd:LPTSTR;
shi502_permissions: DWORD;
shi502_max_uses: DWORD;
shi502_current_uses: DWORD;
shi502_reserved: DWORD;
shi502_security_descriptor: PSECURITY_DESCRIPTOR;
end;
{WinNT/2000}
function ShareResourceEx(ServerNameChar;FilePathChar):Integer;
var
MyShare : Share_Info502;
PMyShare : ^Share_Info502;
begin
MyShare.shi502_netname:='CNVSHARE' {共享名称}
MyShare.shi502_type := STYPE_DISKTREE; {共享类型:0:共享目录;1:共享打印机}
MyShare.shi502_remark := 'HELLO'; {备注}
MyShare.shi502_path := FilePath; {共享目录}
MyShare.shi502_permissions:=0; {许可}
MyShare.shi502_max_uses:= 5; {同时连接用户数}
MyShare.shi502_current_uses:=10; {可连接用户数}
MyShare.shi502_reserved:=0;
MyShare.shi502_security_descriptor:=nil;
MyShare.shi502_PassWd:=''; {口令}
PMyShare := @MyShare;
Result := NetShareAdd(ServerName,502,PMyShare,SizeOf(MyShare));
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ShareResourceEx(nil, pchar(UpperCase(Edit1.Text)));
end;