Solved

File search (shares)

Posted on 2002-03-28
3
300 Views
Last Modified: 2012-05-04
Hello,

I need some code on how to search for files on a share.

The share is \\Computername\c$
I also have to login to activate the share.

This is the code i use at this moment :

procedure GetFiles(DirStr: string; filelist: TList);
var DirInfo: TSearchRec;
   r : Integer;
   fr: PFile;
   pattern: String;
begin
 pattern := ExtractFileName(DirStr);
 if Pos('*', pattern) > 0 then
   DirStr := ExtractFilePath(DirStr)
 else
   pattern := '*.*';
 if DirStr[Length(DirStr)] <> '\' then
   DirStr := DirStr + '\';
 if SetCurrentDir((DirStr)) then
 begin
   r := FindFirst(pattern, FaAnyfile, DirInfo);
   while r = 0 do
   begin
     if (DirInfo.Attr and faDirectory) = 0 then
     begin
       New(fr);
       fr.filename := DirStr + DirInfo.Name;
       fr.filedate := FileDateToDateTime(DirInfo.Time);
       filelist.Add(fr);
     end;
     r := FindNext(DirInfo);
   end;
   FindClose(DirInfo);
   r := FindFirst('*.*', FaAnyfile, DirInfo);
   while r = 0 do
   begin
     if (DirInfo.Attr and faDirectory) <> 0 then
       if (DirInfo.Name <> '.') and (DirInfo.Name <> '..') then
// comment out the next line to exclude system directories
//          if (DirInfo.Attr and faSysFile) = 0 then
           GetFiles(DirStr + DirInfo.Name + '\' + pattern, filelist);
     r := FindNext(DirInfo);
   end;
   FindClose(DirInfo);
 end;
end;

0
Comment
Question by:Vincentg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Expert Comment

by:ginsonic
ID: 6904487
listening
0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6905661
hi,
findfirst etc can search shared drives if you pass it \\computername\sharename\ but what system is it for?
(its different procedure to logon for different systems)

win9* use WNetVerifyPassword (mpr.dll)
winnt/2k use logonuser()

or if you can add the drive as a mapped drive you could do via WNetAddConnection
0
 
LVL 1

Expert Comment

by:drnadeem
ID: 6909734
listening
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi application Soap connection 5 133
Delphi Yen format 3 62
How to convert memory stream to PDF file 6 182
how to resize animated Gif image in delphi ? 1 45
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question