Форум: "Сети";
Текущий архив: 2008.08.10;
Скачать: [xml.tar.bz2];
ВнизЗакрыть подключение через NetFileClose Найти похожие ветки
← →
Elen © (2007-10-08 15:12) [0]Мастера, подскажите пожалуйста я хочу отключать все копирования по локалке на мой компьютер если файлы копируемые мне имеют некое расширение. Делаю так :
unit Unit1;
interface
uses netapi,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, abfComponents, RxNotify, ExtCtrls;
type
TSessionInfo50 = packed record
sesi50_cname : PChar;
sesi50_username : PChar;
sesi50_key : Cardinal;
sesi50_num_conns : Word;
sesi50_num_opens : Word;
sesi50_time : Cardinal;
sesi50_idle_time : Cardinal;
sesi50_protocol : Byte;
pad1 : Byte;
end;
TSessionInfo502 = packed record
Sesi502_cname: PWideChar;
Sesi502_username: PWideChar;
Sesi502_num_opens: DWORD;
Sesi502_time: DWORD;
Sesi502_idle_time: DWORD;
Sesi502_user_flags: DWORD;
Sesi502_cltype_name: PWideChar;
Sesi502_transport: PWideChar;
End;
PSessionInfo502 = ^TSessionInfo502;
TSessionInfo502Array = array[0..512] of TSessionInfo502;
PSessionInfo502Array = ^TSessionInfo502Array;
TFileInfo3 = packed record
fi3_id : DWORD;
fi3_permissions : DWORD;
fi3_num_locks : DWORD;
fi3_pathname : PWChar;
fi3_username : PWChar;
end;
PFileInfo3 = ^TFileInfo3;
TFileInfo3Array = array[0..512] of TFileInfo3;
PFileInfo3Array = ^TFileInfo3Array;
//**************************************************************************
TForm1 = class(TForm)
ListBox1: TListBox;
RxFolderMonitor1: TRxFolderMonitor;
Timer1: TTimer;
procedure RxFolderMonitor1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function NetSessionDel(ServerName,
UncClientName,
Username:PWChar):DWORD; stdcall;
function NetSessionEnum(ServerName,
UncClientName,Username: PWChar;
Level: DWORD;
bufptr: Pointer;
prefmaxlen: DWORD;
entriesread, totalentries,resume_handle: LPDWORD):DWORD;
stdcall; external "netapi32.dll";
function NetFileClose(ServerName:PWideChar;
FileId:DWORD):DWORD; stdcall; external "netapi32.dll";
Function NetSessionDel(ServerName,
UncClientName,
Username:PWChar):DWORD;
stdcall; external "netapi32.dll";
function NetFileEnum(servername,
basepath,
username: PWChar;
level: DWORD;
bufptr: Pointer;
prefmaxlen: DWORD;
entriesread,
totalentries,
resume_handle: LPDWORD):DWORD; stdcall; external "netapi32.dll";
var SessionInfo50: array [0..512] of TSessionInfo50;
SessionInfo502 : PSessionInfo502Array;{}
Form1: TForm1;
TotalEntries,EntriesReadNT: DWORD;
implementation
{$R *.dfm}
procedure TForm1.RxFolderMonitor1Change(Sender: TObject);
var j,i:integer; FileInfoNT: PFileInfo3Array;
TotalEntriesF,EntriesReadF: DWORD;
EntriesRead,TotalAvial: Word;
s:string;ext:string; tf:TFileInfo3;
begin
s:=""; caption:="fdsf";
EntriesReadF:=0;
EntriesRead:=0;
TotalEntriesF:=0;
TotalAvial:=0;
TotalEntries:=0;
RxFolderMonitor1.Active:=false;
if NetFileEnum(nil,nil,nil,3,@FileInfoNT,DWORD(-1),@entriesreadF, @totalentriesF, nil)=0 then begin
//********* FOR ******************
j:=1;
for j:=0 to EntriesReadF-1 do begin {}
if FileInfoNT<>nil then begin
s:=FileInfoNT[j].fi3_pathname;
ext:=ExtractFileExt(FileInfoNT[j].fi3_pathname);
if ext=".exe" then begin
NetFileClose(nil,FileInfoNT[j].fi3_id);
s:="Del "+s;
end;
ListBox1.Items.add(s);{}
end;
end;
//******* END FOR ****************{}
end;
//******* END FOR ****************{}
RxFolderMonitor1.Active:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Left:=0;
end;
end.
Но почему то закрытие происходит только один раз.
Подскажите что я не учитываю.?
← →
Сергей М. © (2007-10-08 17:18) [1]Отладчик тебе на что дан ?
Страницы: 1 вся ветка
Форум: "Сети";
Текущий архив: 2008.08.10;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.006 c