Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

File search (shares)

Posted on 2002-03-28
3
Medium Priority
?
304 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 100 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

604 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