Solved

File search (shares)

Posted on 2002-03-28
3
299 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 119
Correct Component for Shopping Cart. 2 104
Convert GUI app into console app for Win32 Env 5 98
Tidtcpserver listening on multiports? 1 26
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now