> ----------
> From:         [EMAIL PROTECTED][SMTP:[EMAIL PROTECTED]]
> Sent:         Friday, January 15, 1999 9:25:39 PM
> To:   Multiple recipients of list delphi
> Subject:      [DUG]:  Re: NetFileEnum
> Auto forwarded by a Rule
> 
> 
This is a little example using Colin Wilson's Lan Manager headers available at:
http://www.wilsonc.demon.co.uk/delphi.htm

I have tested this against my NT workstation, but not a NT server...


------
This works ONLY on NT.


uses lmGlobal, lmSharew;

procedure ListFiles (const server, user : string; list : TStrings);
var
  wUser : WideString;
  wServer : WideString;
  err : Integer;
  i, entriesRead, totalEntries : DWORD;
  buffer : pointer;
  info : PFILE_INFO_3;
  resume_handle : Integer;
begin
  wUser := user;
  wServer := server;
  resume_handle:=0;
  err := NetFileEnum (PWideChar (wServer), Nil, PWideChar (wUser), 3,
PWideChar (buffer), MAX_PREFERRED_LENGTH, entriesRead, totalEntries,
resume_handle);
  if err = NERR_Success then
  try
    info := PFILE_INFO_3 (buffer);
    for i := 0 to entriesRead - 1 do
    begin
      list.Add (info^.fi3_pathname);
      Inc (info)
    end
  finally
    NetAPIBufferFree (buffer)
  end
  else
    raise Exception.CreateFmt ('Error %d enumerating files', [err])
end;


and you can get a list of open files on the local machine like:

  ListFiles('','',listbox1.items);


> Hi all,
> 
> I have a question about the network API.
> 
> I often need to know what file is in use on our server. With NT, this is not
> easy, you can look through the open file list looking through the hundreds
> of files open and try and find the one you want.
> 
> I have found in the Win 32 API help a ported Lab Manager function called
> NetFileEnum which would do what I am after. The problem is that I can't find
> this file referenced anywhere in the pas files.
> 
> Any one know what/where I should be looking?
> 
> Any info appreciated.
> 
> Colin Fraser
> Hill Laboratories
> Hamilton
> New Zealand
> 
> ---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to