unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ShellApi, LmShare, LmAccess;
type
TForm1 =
class(TForm)
Label1: TLabel;
ProgressBar1: TProgressBar;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
const
NERR_Success = 0;
MAX_PREFERRED_LENGTH = DWORD(-1);
type
NET_API_STATUS =
type DWORD;
PSHARE_INFO_0 = ^SHARE_INFO_0;
SHARE_INFO_0 =
packed record
shi0_netname : PWChar;
end;
type
PSHARE_INFO_2 =^SHARE_INFO_2;
SHARE_INFO_2 =
packed record
shi2_netname : PWChar;
shi2_type : Dword;
shi2_remark : PWChar;
shi_permissions : DWord;
shi2_max_uses : DWord;
shi2_current_uses : DWord;
shi2_path : PWChar;
shi2_passwd : PWChar;
end;
var
reg: TRegistry;
buffer1, buffer2, buffer3:
array [1..32]
of Char;
i: Integer;
ipaddress, subnetmask, DefaultGateway:
string;
Adapter, Adapter_Key:
string;
stringlist: TStrings;
implementation
uses ipadresse;
{$R *.dfm}
function NetApiBufferFree(
const Buffer : Pointer
) : NET_API_STATUS;
stdcall;
external '
netapi32.dll';
function NetShareEnum(
const servername : PWChar;
const level : DWord;
const bufptr : Pointer;
const prefmaxlen : DWord;
const entriesread : PDWord;
const totalentries : PDWord;
const resume_handle : PDWord
) : NET_API_STATUS;
stdcall;
external '
netapi32.dll';
procedure TForm1.Button3Click(Sender: TObject);
var
si2Work : PSHARE_INFO_2;
si2Save : PSHARE_INFO_2;
dwEntriesRead : DWORD;
dwTotalEntries : DWORD;
i : DWORD;
begin
if NetShareEnum(
nil,2,@si2Work,MAX_PREFERRED_LENGTH,@dwEntriesRead,@dwTotalEntries,
nil) <> Nerr_Success
then exit;
try
si2Save := si2Work;
for i := 1
to dwEntriesRead
do
begin
if si2Save.shi2_type = STYPE_DISKTREE
then
memo1.lines.Add(si2Save.shi2_netname);
inc(si2Save);
end;
finally
NetApiBufferFree(si2Work);
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
share: PSHARE_INFO_2;
err: DWord;
begin
Share.shi2_netname:='
SBK';
share.shi2_type:=STYPE_DISKTREE;
share.shi_permissions:=ACCESS_ALL;
share.shi2_path:='
c:\\mysql';
NetShareAdd('
',2,@Share,@err);
ShowMessage(Inttostr(err));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
end.