各位大侠,小弟照葫芦画瓢,用了这个函数后,本机上目录的共享设置以没有问题了,但现在地问题
是我需要能够设置同一域内其他机器的共享目录(网上邻居中能看见),我看了NetShareAdd
的帮助,第一个参数应该就是说需要设置共享目录的机器的机器名,但我试了后不成功,现在
把程序附在下面,请各位给找找问题:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,AccCtrl;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TSHARE_INFO_502 = record
shi502_netname: PWideChar;
shi502_type: DWORD;
shi502_remark: PWideChar;
shi502_permissions: DWORD;
shi502_max_uses: DWORD;
shi502_current_uses: DWORD;
shi502_path: PWideChar;
shi502_passwd: PWideChar;
shi502_reserved: DWORD;
shi502_security_descriptor: PSECURITY_DESCRIPTOR;
end;
PBYTE = ^BYTE;
PDWORD = ^DWORD;
function NetShareAdd(servername
Char; level: DWORD; buf: PBYTE;
parm_err: PDWORD ): DWORD; stdcall;
var
Form1: TForm1;
implementation
function NetShareAdd; external 'netapi32.DLL' name 'NetShareAdd';
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
ServerName
char;
si: TSHARE_INFO_502;
r: DWORD;
parm_err
Dword;
begin
si.shi502_netname := 'temp4'; (共享名)
si.shi502_type := 0; //STYPE_DISKTREE
si.shi502_remark := nil;
si.shi502_max_uses := $FFFFFFFF;
si.shi502_current_uses := 10;
si.shi502_path := 'f:/sango3'; (原路径)
si.shi502_passwd := nil;
si.shi502_reserved := 0;
si.shi502_security_descriptor := nil;
si.shi502_permissions:=TRUSTEE_ACCESS_ALL;
ServerName:=stralloc(200);
strpcopy(ServerName,'vodserver'); ('vodserver'是机器名)
try
r := NetShareAdd(ServerName, 502, @si, parm_err );
Finally
strdispose(ServerName);
end;
Edit1.Text := Format( '%d', [r] );
Edit2.Text:=inttostr(parm_err);
end;
end.
NetShareAdd的返回值老是53,不知道是什么意思,也找不到相应的错误意义
高手们多帮忙,原本说今天要搞定的,跟老板又拖了拖,说是周一,请大家在这两天内无论如何
帮我想想办法啊!!!
多谢多谢!