Alexander V. Meshkov дата публикации 02-07-2001 00:00 Работа с локальной сетью - NetShareAdd
Долго и упорно мучался по освоению этой функции и, наконец, решил эту
проблему (не без помощи добрых людей :).
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
Share_INFO_2= record
shi2_netname:PWideChar;
shi2_type:DWORD;
shi2_remark:LPTSTR;
shi2_permissions:DWORD;
shi2_max_uses:DWORD;
shi2_current_uses:DWORD;
shi2_path:PWideChar;
shi2_passwd:LPTSTR;
end;
PShare_INFO_2 = ^Share_INFO_2;
LPShare_INFO_2 = ^Share_INFO_2;
SHARE_INFO_502 =record
shi502_netname: PCHAR;
shi502_type: DWORD;
shi502_remark: PCHAR;
shi502_permissions: DWORD;
shi502_max_uses: DWORD;
shi502_current_uses: DWORD;
shi502_path: PCHAR;
shi502_passwd: PCHAR;
shi502_reserved: DWORD;
shi502_security_descriptor: PSECURITY_DESCRIPTOR;
end;
PSHARE_INFO_502= ^SHARE_INFO_502;
LPSHARE_INFO_502=^SHARE_INFO_502;
const
STYPE_DISKTREE = $0001;
ACCESS_READ = $0001;
var
Form1: TForm1;
F:Cardinal;
function NetShareAdd(
Server : PwideChar;
level : cardinal;
Buf : Pointer;
var Parm_Err : DWORD):Cardinal;stdcall; external 'netapi32.dll' name 'NetShareAdd';
implementation
procedure TForm1.Button1Click(Sender: TObject);
var
buf:Pointer;
UserInf:Share_INFO_2;
UserInf502:Share_INFO_502;
err:dWord;
begin
err:=0;
f:=0;
UserInf.shi2_netname:='test';
UserInf.shi2_type:=0;
UserInf.shi2_remark:='test';
UserInf.shi2_permissions:=1;
UserInf.shi2_max_uses:= 1;
UserInf.shi2_current_uses:=0;
UserInf.shi2_path:='C:\test';
UserInf.shi2_passwd:=nil;
GetMem(Buf ,sizeof(UserInf));
F:=NetSHAREAdd(nil,2,@UserInf,err);
FreeMem(Buf);
end;
end.
[TObject] [TComponent] [TForm] [TStream] [THandleStream] [TFileStream] [TButton] [TReader] [TWriter] [Зашаренные ресурсы]
Обсуждение материала нет сообщений |